<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
</head>
<body style="display:none;">
  <!-- ========= -->
  <!--   HTML    -->
  <!-- ========= -->


  
  <div id="container">
    <div id="expressioneditor-container">
    
    </div>
   <div id="containerdata" ></div>
   <div class="modal" id="RecourseModal" role="dialog" aria-labelledby="myModalLabel">
      <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title tr step-1" data-step="1" id="myModalLabel">Select Resource</h4>
            <h4 class="modal-title tr step-2" data-step="2" id="myModalLabel">Select Resource</h4>
          </div>
          
          <div class="modal-body step step-1">
            <span id="RecourseControls">
              <select class="form-control" id="RecourseName" placeholder="Recourse Name">
              </select>
            </span>
            <span id="NoResources">
              <span class="tr">No resources found.</span>
              <div class="tr" style="color:gray;font-size:small;margin-top:10px">You can create resource with "+ Create New Resource" button which is located in the panel to the right.</div>
            </span>
          </div>

          <div class="modal-body step step-2" style="padding-top:5px">
            <span id="RecourseControls">
              <input type="checkbox" id="ResourceReuse" checked /> <label style="margin-bottom:0px" for="ResourceReuse" class="tr res-margin">Reuse Resource</label>
              <div class="tr" style="color:gray;font-size:small">Take new or old resource during current resource request.</div>
              <input type="checkbox" id="ResourceDontDie" style="margin-top:15px"/> <label for="ResourceDontDie" class="tr res-margin" style="margin-bottom:0px">Don't end application if not exists</label>
              <div class="tr" style="color:gray;font-size:small">By default script will stop after resource is finished. You can use this option to complete not the entire script, but only the thread.</div>
            </span>
          </div>

          <div class="modal-footer">
            <button type="button" class="btn btn-primary rescontinue standartbutton tr step step-1" data-step="1">Next</button>
            <button type="button" class="btn btn-primary resok standartbutton tr step step-2" data-step="2" data-dismiss="modal">Ok</button>
            <button type="button" class="btn btn-default standartbutton tr" data-dismiss="modal">Cancel</button>
          </div>
        </div>
      </div>
    </div>

    <div class="modal " id="VariableModal" role="dialog" aria-labelledby="myModalLabel">
      <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title tr" id="myModalLabel">Select Variable</h4>
          </div>
          <div class="modal-body">
            <select class="form-control" id="VariableName" placeholder="Variable Name">
            </select>
            <span id="NoVariable" class="tr">No variables found.</span>
            <div class="tr" style="color:gray;font-size:small;margin-top:10px">Use "Set Variable" action to create variable.</div>

          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-primary varok standartbutton tr" data-dismiss="modal">Ok</button>
            <button type="button" class="btn btn-default standartbutton tr" data-dismiss="modal">Cancel</button>
          </div>
        </div>
      </div>
    </div>

    <div class="modal" id="FunctionModal" role="dialog" aria-labelledby="myModalLabel">
      <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title tr" id="myModalLabel">Select Function</h4>
          </div>
          <div class="modal-body">
            <select class="form-control" id="FunctionNameInput" placeholder="Function Name">
            </select>
            <span id="NoFunctionFound" class="tr">No functions found.</span>

          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-primary funcok standartbutton tr" data-dismiss="modal">Ok</button>
            <button type="button" class="btn btn-default standartbutton tr" data-dismiss="modal">Cancel</button>
          </div>
        </div>
      </div>
    </div>

    <div class="modal" id="LabelModal" role="dialog" aria-labelledby="myModalLabel">
      <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title tr" id="myModalLabel">Select Label</h4>
          </div>
          <div class="modal-body">
            <select class="form-control" id="LabelNameInput" placeholder="Label">
            </select>
            <span id="NoLabelFound" class="tr">No label found. Create one with Set label action.</span>

          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-primary labelok standartbutton tr" data-dismiss="modal">Ok</button>
            <button type="button" class="btn btn-default standartbutton tr" data-dismiss="modal">Cancel</button>
          </div>
        </div>
      </div>
    </div>

    <div class="modal " id="TimeoutModal" role="dialog" aria-labelledby="myModalLabel">
      <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title tr" id="myModalLabel">Maximum time to perform an action.</h4>
          </div>
          <div class="modal-body">
            <div class="row">
              <div class="col-lg-12">
                <div class="input-group">
                  <input type="number" id="TimeoutValue" class="form-control"/>
                  <span class="input-group-btn">
                    <button class="btn btn-default tr" type="submit">seconds</button>
                  </span>
                </div>
              </div>
            </div>
            <div class="row">
              <div class="col-lg-12">
               <span class="tr" style="font-size:small;color:gray">Use 'Timeout' action to set default timeout.</span>
              </div>
            </div>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-primary timeoutok standartbutton tr" data-dismiss="modal">Ok</button>
            <button type="button" class="btn btn-default timeoutdefault standartbutton tr" data-dismiss="modal">Default</button>
            <button type="button" class="btn btn-default standartbutton tr" data-dismiss="modal">Cancel</button>
          </div>
        </div>
      </div>
    </div>


    <div class="modal text-center" id="WaitingModal" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-keyboard="false" data-backdrop="static">
    <div class="vertical-alignment-helper">
        <div class="modal-dialog vertical-align-center">
            <div class="modal-content">
                <div class="modal-body" style="margin-top:10px;margin-bottom:10px"><span class="tr">Executing Action</span>: <span class="tr text-danger" id="WaitingActionName">Unknown</span>
                
                <p style="margin-top:30px"><span id="InterruptMessage" class="tr" style="display:none">Trying to interrupt ...</span><a href="#" id="WaitingDisable" class="btn btn-default tr">Interrupt</a></p>
                </div>
                
            </div>
        </div>
    </div>
</div>

    

  </div>

  <!-- ========= -->
  <!-- TEMPLATES -->
  <!-- ========= -->

  <script type="text/template" id="targetfields">
    <span id="target-data" style="display:none">
      <%= _.template($('#input_constructor').html())({id:"TargetUrl", description:tr("Target url"), default_selector: "string", disable_int:true, value_string: "*"}) %>
      <%= _.template($('#input_constructor').html())({id:"TargetTabNumber", description:tr("Target tab number"), default_selector: "string", value_string: "*", value_number: 0}) %>
    </span>
  </script>

  <script type="text/template" id="movefields">
    <span id="move-data" style="display:none">
      <%= _.template($('#input_constructor').html())({id:"Speed", description:tr("Speed"), default_selector: "expression", disable_int:true, disable_string:true, value_string: "100"}) %>
      <%= _.template($('#input_constructor').html())({id:"Gravity", description:tr("Gravity"), default_selector: "expression", disable_int:true, disable_string:true, value_string: "6"}) %>
      <%= _.template($('#input_constructor').html())({id:"Deviation", description:tr("Deviation"), default_selector: "expression", disable_int:true, disable_string:true, value_string: "2.5"}) %>
    </span>
  </script>

  <script type="text/template" id="expressioneditor">
    

    <div id="expressioneditor-list"></div>
    <div id="expressioneditor-constructor">
      
      <div id="expressioneditor-overlay">
        <div class="expressioneditor-overlay-title"><h2><span class="tr">Enter Value</span>:</h2></div>
        <div class="expressioneditor-overlay-data"><%= _.template($('#input_constructor').html())({id:"ExpressionValue", description:tr(""), default_selector: "string",disable_editor:true,min_number:-999999}) %></div>
        <div class="expressioneditor-overlay-buttons">
          <a href="#" class="btn btn-success btn-sm expressioneditor-button-accept" id="expressioneditor-valueok" ><span class="tr">OK</span></a><a href="#" id="expressioneditor-valuecancel" class="btn btn-danger btn-sm expressioneditor-button-accept" ><span class="tr">CANCEL</span></span></a>
        </div>
      </div>

      <div id="expressioneditor-overlay-confirm">
        <div class="expressioneditor-overlay-title"><h2><span class="tr">Confirm Changes</span>:</span></h2></div>
        <div class="expressioneditor-overlay-olddata"><span class="tr">Replace old value</span> <span id="expressioneditor-old-value"></span> <span class="tr">with new one</span>:</div>
        <div class="expressioneditor-overlay-data"><%= _.template($('#input_constructor').html())({id:"ExpressionValueConfirm", description:tr(""), default_selector: "expression",disable_editor:true,disable_int:true,disable_string:true}) %></div>
        <div class="expressioneditor-overlay-buttons">
          <a href="#" class="btn btn-success btn-sm expressioneditor-button-accept" id="expressioneditor-confirmok" ><span class="tr">OK</a><a href="#" id="expressioneditor-confirmcancel" class="btn btn-danger btn-sm expressioneditor-button-accept" ><span class="tr">CANCEL</span></a>
        </div>
      </div>

      <div class="expressioneditor-container">
        
        <button type="button" class="btn btn-info expressioneditor-add-string btn-sm"><span class="tr">STRING</span> +</button>
        <button type="button" class="btn btn-info expressioneditor-add-int btn-sm"><span class="tr">INT</span> +</button>
        <button type="button" class="btn btn-info expressioneditor-add-expression btn-sm"><span class="tr">EXPRESSION</span> +</button>
        
        <span id="expressioneditor-expression"></span>
        <div class="expressioneditor-bottom-titlebar">
           <a href="#" class="btn btn-success btn-sm expressioneditor-button-accept" id="expressioneditor-ok" ><span class="tr">ACCEPT</span> &gt;</a>   <a href="#" id="expressioneditor-cancel" class="btn btn-danger btn-sm expressioneditor-button-accept" ><span class="tr">CANCEL</tr></a>
        </div>
        <div class="expressioneditor-navigator">
        </div>
      </div>
    </div>
  </script>

  <script type="text/template" id="expressioneditor-list-item">
    <div><a href="#" class="expressioneditor-tool" data-name="<%= name %>"><%= name_translate %></a> : <%= description %></div>
  </script>


  <script type="text/template" id="main">
    <div class="leftactionpaneltitledrop" style="display:none">
      <i class="fa fa-trash-o" aria-hidden="true"></i>
    </div>

    <div class="searchbar">
      <div class="container-fluid">
        <div class="input-group input-group-sm">
          <span class="input-group-addon" id="basic-addon1"><i class="fa fa-search" aria-hidden="true"></i></span>
          <input type="text" class="form-control typeahead" id="searchinput" placeholder="What to search?" aria-describedby="basic-addon1">
          <span class="input-group-btn">
            <button class="btn btn-default" type="button" id="searchinputclear"><i class="fa fa-times" aria-hidden="true"></i></button>
          </span>
        </div>
      </div>
    </div>
    <div class="actions">
      <div class="leftpanel">
        <button type="button" id="showbookmarks" class="btn btn-default btn-sm" style="margin-bottom:5px"><i class="fa fa-bookmark" aria-hidden="true"></i></button>
        <button type="button" id="showhistory" class="btn btn-default btn-sm"><i class="fa fa-history" aria-hidden="true"></i></button>
      </div>
      <div class="leftactionpanel" style="display:none">
        
        <div class="leftactionpaneltitle"></div>
        <div class="leftactionpaneltitlebody" style="margin-top:3px;margin-bottom:3px">

        </div>
        
      </div>
      <div class="container-fluid mainscreen" >
        <div class="panel-group" style="margin-bottom: 0px;">
            <% var group = null; %>
            <% _.each(data, function(task) { %>
                <% if(typeof(task.type) != "undefined" && task.type == "group") { %>
                  <% group = task.name; %>
                  <span data-group="<%= task.name %>" data-group-all="<%= task.name %>"  ondragstart="return false;" ondrop="return false;">
                    <a href="#" data-group="<%= task.name %>" data-group-all="<%= task.name %>" class="groupshow" style="color:black" >
                      <div class="panelgrid text-center" data-toggle-none="tooltip" data-placement-none="auto" title-none="<%=task.info%>">
                        
                        <div class="panelgridtitle"><div class="panelgridtitleinner"><%= task.description %></div></div>
                        <div class="panelgridimage">
                          <span class="helper"></span>
                          <% if(typeof(task.icon) != "undefined") { %>
                            <img src="<%= task.icon %>" class="center-block img-responsive" />
                          <% } else { %>
                            <img src="../icons/module.png" class="center-block img-responsive" />
                          <% } %>
                        </div>
                      </div>
                    </a>
                    <span data-group="<%= task.name %>" style="display:none">
                      <div class="returntomaindiv">
                        <a href="#" class="returntomain"><i class="fa fa-long-arrow-left" aria-hidden="true"></i> <span class="tr" style="font-size:smaller">Return to main screen</span></a>
                      </div>
                      <hr style="margin-top:5px;margin-bottom:5px" />
                      <% if(typeof(task.info) != "undefined") { %>
                        <div class="panelgriddescription"><%= task.info %>
                        </div>
                      <% } %>
                      <div style="clear: both;"></div>

                      
                    </span>
                  </span>
                <% }else{ %>
                    <a class="toolbutton" href="#!/<%= task.ref %>" data-placement="right" title="<%= task.description %>" data-name="<%= task.name %>" data-ref="<%= task.ref %>" data-group="<%= group %>" style="display:none">
                      <div class="tool" >
                         <span class="toolinner"><%= task.name %></span>
                      </div>
                    </a>
                <% } %>
            <% }); %>
            </div>
          </div>
        </div>
      </div>
    </div>
  </script>

  <script type="text/template" id="back">
    <div class="container-fluid back" >
      <div class="col-xs-12">
        
        <div id="validation" class="text-muted"><%= _GobalModel.GetPageInfo() || name %></div>
        <hr style="margin-top:5px;margin-bottom:5px"/>

        

        <a tabindex="-1" class="btn btn-success standartbutton tr" id="ok">Ok</a> <a tabindex="-1" class="btn btn-danger standartbutton tr" href="#!/" id="backtomain">Cancel</a>

        <% if(typeof(use_waiter) != "undefined"){ %>
          <a href="#" tabindex="-1" id="use-waiter" class="<%= (typeof(waiter_enabled) != "undefined" && waiter_enabled) ? "" : "use-waiter-disabled" %> trtitle" data-enabled="<%= (typeof(waiter_enabled) != "undefined" && waiter_enabled) ? "true" : "false" %>" data-toggle="tooltip" data-placement="top" title="Wait full page load after this action"><i class="fa fa-clock-o" aria-hidden="true"></i></a>

        <% } %>

        <% if(typeof(use_target) != "undefined"){ %>
          <a href="#" tabindex="-1" id="use-target" class="<%= (typeof(target_enabled) != "undefined" && target_enabled) ? "" : "use-target-disabled" %> trtitle" data-enabled="<%= (typeof(target_enabled) != "undefined" && target_enabled) ? "true" : "false" %>" data-toggle="tooltip" data-placement="top" title="Toggle target. Apply this action only to specific url or to specific tab."><i class="fa fa-dot-circle-o" aria-hidden="true"></i></a>

        <% } %>

        <% if(typeof(use_timeout) != "undefined"){ %>
          <a href="#" tabindex="-1" id="use-timeout" data-value="<%= (typeof(timeout_value) != "undefined" && timeout_value > 0) ? timeout_value : "0" %>" class="<%= (typeof(timeout_value) != "undefined" && timeout_value > 0) ? "" : "use-timeout-disabled" %> trtitle"  data-enabled="<%= (typeof(timeout_value) != "undefined" && timeout_value > 0) ? "true" : "false" %>" data-toggle="tooltip" data-placement="top" title="Maximum time to perform an action.">
            <i class="fa fa-hourglass-end" aria-hidden="true" ><small id="timeout-is-default" class="tr">default</i><small id="timeout-val"></i><%= (typeof(timeout_value) != "undefined" && timeout_value > 0) ? ("" + timeout_value) : "" %></small></a>
        <% } %>

        <% if(typeof(use_move) != "undefined"){ %>
          <a href="#" tabindex="-1" id="use-move" class="<%= (typeof(move_enabled) != "undefined" && move_enabled) ? "" : "use-move-disabled" %> trtitle" data-enabled="<%= (typeof(move_enabled) != "undefined" && move_enabled) ? "true" : "false" %>" data-toggle="tooltip" data-placement="top" title="Tweak speed and other parameters for mouse move."><i class="fa fa-sliders" aria-hidden="true"></i></a>
        <% } %>


        <% if(visible){ %>
          <div class="btn-group" role="group" id="executetype">
            <button tabindex="-1" type="button" class="btn <%= (action == "execute") ? "btn-info":"btn-default" %> " data-action="execute"><%= tr("Only Execute") %></button>
            <button tabindex="-1" type="button" class="btn <%= (action == "add") ? "btn-info":"btn-default" %> " data-action="add"><%= tr("Only Add") %></button>
            <button tabindex="-1" type="button" class="btn <%= (action == "executeandadd") ? "btn-info":"btn-default" %> " data-action="executeandadd"><%= tr("Execute And Add") %></button>
          </div>
        <% } %>
      </div>
    </div>
  </script>

  <script type="text/template" id="variable_constructor">
    <span data-preserve="true" data-preserve-type="var" data-preserve-id="<%= id %>">
      <div class="col-xs-12">
        <form class="form-horizontal">
          <div class="form-group">
            <div class="col-xs-12">
              <div class="input-group">
                <input class="form-control variable-input" style='text-transform: uppercase;color:#529653;'  type="text" id="<%= id %>" placeholder="<%= description %>" value="<%= default_variable %>" data-variable-constructor="true" <%= (typeof(append_mode) != "undefined") ? "data-append-array=\"true\"" : "" %> >
                
                <ul class="dropdown-menu input-field-dropdown dropdown-align dropdown-black">
                  <li>
                    <a tabindex="-1" href="#" data-toggle="modal" data-result-target="#<%= id %>" class="var" data-toggle="modal" data-target="#VariableModal" data-result-target="#<%= id %>" <%= (typeof(disable_locals) != "undefined") ? "disable_locals=\"true\"" : "" %> <%= (typeof(enable_globals) != "undefined") ? "":"disable_globals=true" %> >
                      <i class="fa fa-at"/>
                        <span class="tr">Insert existing variable</span>
                    </a>
                  </li>
                </ul>

                <span class="input-group-addon input-description"><%= description %></span>
              </div>
            </div>

          </div>
        </form>
      </div>
    </span>
  </script>

  <script type="text/template" id="resource_constructor">
    <span data-preserve="true" data-preserve-type="var" data-preserve-id="<%= id %>">
      <div class="col-xs-12">
        <form class="form-horizontal">
          <div class="form-group">
            <div class="col-xs-12">
              <div class="input-group">
                <input class="form-control resource-input" type="text" id="<%= id %>" placeholder="<%= description %>" value="" data-resource-constructor="true" />

                <ul class="dropdown-menu input-field-dropdown dropdown-align dropdown-black">
                  <li>
                    <a tabindex="-1" href="#" data-toggle="modal" data-result-target="#<%= id %>" class="res" data-toggle="modal" data-target="#RecourseModal" data-result-target="#<%= id %>">
                      <i class="fa fa-database"/>
                        <span class="tr">Select resource</span>
                    </a>
                  </li>
                </ul>

                <span class="input-group-addon input-description"><%= description %></span>
              </div>
            </div>
          </div>
        </form>
      </div>
    </span>
  </script>

  <script type="text/template" id="path">
    <div class="path" >

      <div class="col-xs-12">
        <form class="form-horizontal" onsubmit="return false;">
          <div class="form-group">
            <div class="col-xs-12">


              <% if(selector["is_image"]){ %>
                <table id="ImageTable">
                  <tr>
                    <td align="center">
                      <a href="#" id="ImageDataRef">
                        <img id="ImageData" style="max-width:300px;"/>
                      </a>
                    </td>
                    <td style="width:100%;padding-left: 15px;" valign="top">
                      
                      <div class="path-options">
                        <% if(typeof(disable_options) == "undefined"){ %>
                          <span <%= (typeof(hide_options) != "undefined") ? 'style="display:none"':'' %> >
                            <div class="checkbox checkbox-info" style="min-height: 20px;"><input tabindex="-1" id="checkbox-wait-element" type="checkbox" class="form-control-no-border" <%= (typeof(waitelement) == "boolean" && waitelement == false) ? '':'checked="checked"' %> > <label for="checkbox-wait-element" class="tr">Wait for element.</label></div>
                            <div class="checkbox checkbox-danger" style="min-height: 20px;"><input tabindex="-1" id="checkbox-fail-action" type="checkbox" class="form-control-no-border" <%= (typeof(failaction) == "boolean" && failaction == false) ? '':'checked="checked"' %> > <label for="checkbox-fail-action" class="tr">Fail thread if element not found.</label></div>
                          </span>
                        <% } %>                            
                        <div class="checkbox checkbox-success" style="min-height: 20px;"><input tabindex="-1" id="checkbox-image-show-data" type="checkbox" class="form-control-no-border"> <label for="checkbox-image-show-data" class="tr">Additional parameters.</label></div>
                        <div style="clear: both;"></div>
                      </div>

                    </td>
                  </tr>
                </table>
                <div id="ImageBase64Container" style="display:none">
                  <div style="margin-bottom:5px">
                    <%= _.template($('#input_constructor').html())({id:"Scroll", description:tr("Scroll to search for image"), default_selector: "string", disable_int:true, value_string: "scroll", variants: ["scroll", "no scroll"], dont_use_top:true,dont_use_col:true}) %>
                  </div>
                  <div style="margin-bottom:5px">
                    <%= _.template($('#input_constructor').html())({id:"Threshold", description:tr("How well the image must fit. 100 - exactly fits, 0 - does not fit at all."), default_selector: "int", disable_string:true, value_number:80, min_number:0, max_number:100, dont_use_top:true,dont_use_col:true}) %>
                  </div>
                  <%= _.template($('#input_constructor').html())({id:"ImageBase64", description:tr("Image data as base64"), dont_use_top:true, dont_use_col:true, default_selector: "expression", disable_int:true, disable_editor:true, disable_string:true, use_textarea:true, size: 4, disable_type_chooser:true, textarea_height: 74}) %>
                </div>

              <% } else { %>
                <% if(typeof(disable_options) == "undefined"){ %>

                  <div class="path-options" <%= (typeof(hide_options) != "undefined") ? 'style="display:none"':'' %> >
                    <div class="checkbox checkbox-one-line checkbox-info" style="margin-right:20px;"><input tabindex="-1" id="checkbox-wait-element" type="checkbox" class="form-control-no-border" <%= (typeof(waitelement) == "boolean" && waitelement == false) ? '':'checked="checked"' %> > <label for="checkbox-wait-element" class="tr">Wait for element.</label></div>
                    <div class="checkbox checkbox-one-line checkbox-danger"><input tabindex="-1" id="checkbox-fail-action" type="checkbox" class="form-control-no-border" <%= (typeof(failaction) == "boolean" && failaction == false) ? '':'checked="checked"' %> > <label for="checkbox-fail-action" class="tr">Fail thread if element not found.</label></div>
                    <div style="clear: both;"></div>
                  </div>
                <% } %>


                <div class="input-group">
                  <input type="text" class="form-control dropdown-menu-path" aria-label="..." id="selector-input">        
                    
                    <ul tabindex="-1" class="dropdown-menu dropdown-menu-css-options dropdown-black" style="<%= (BrowserAutomationStudio_HasPathChoice()) ? "" : "" %>">
                      <% if("css1" in selector && selector["css1"].length > 0) { %>
                        <li><a tabindex="-1" href="#" class="dropdown-menu-css-item"><%= selector["css1"] %></a></li>
                      <% }else{ %>  
                        <li><a tabindex="-1" href="#" class="dropdown-menu-css-item"><%= selector["css"] %></a></li>
                      <% } %>
                      <% if("css2" in selector && selector["css2"].length > 0) { %>
                        <li><a tabindex="-1" href="#" class="dropdown-menu-css-item"><%= selector["css2"] %></a></li>
                      <% } %>

                      <% if("css3" in selector && selector["css3"].length > 0) { %>
                        <li><a tabindex="-1" href="#" class="dropdown-menu-css-item"><%= selector["css3"] %></a></li>
                      <% } %>
                    </ul>

                    <span class="input-group-addon input-description"><span class="tr">Element selector</span> ( <span class="tr">found</span> <span id="PathCount" class="text-info">0</span> )</span>

                    <div class="input-group-btn">
                      <a tabindex="-1" href="#" type="button" class="btn btn-default res" data-toggle="modal" data-target="#RecourseModal" data-result-target="#selector-input" style="border-left:0px;border-right:0px;border-radius:0px" ><i class="fa fa-database"></i></a>            
                    </div>

                    <div class="input-group-btn">
                      <a tabindex="-1" type="button" class="btn btn-default var" data-toggle="modal" data-target="#VariableModal" data-result-target="#selector-input" style="border-right:0px;border-radius:0px" ><i class="fa fa-at"></i></a>
                    </div>

                    <div class="input-group-btn">
                      <button tabindex="-1" type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span id="selector"><%= selector["current"] %></span> <span class="caret"></span></button>
                      <ul class="dropdown-menu dropdown-menu-right">
                        <li><a tabindex="-1" id="css" class="tr">css</a></li>
                        <li><a tabindex="-1" id="match" class="tr">match</a></li>
                        <li><a tabindex="-1" id="xpath" class="tr">xpath</a></li>
                        <li><a tabindex="-1" id="at" class="tr">at</a></li>
                        <li><a tabindex="-1" id="none" class="tr">none</a></li>
                      </ul>
                    </div>

                </div>

              <% } %>


            </div>
          </div>
        </form>
      </div>
    </div>
  </script>

  <script type="text/template" id="input_constructor">
    <span data-preserve="true" data-preserve-type="constr" data-preserve-id="<%= id %>">
      <% if(typeof(dont_use_top) == "undefined"){ %>
        <div class="col-xs-12">
        <form class="form-horizontal">
          <div class="form-group">
          <% } %>
            <% if(typeof(dont_use_col) == "undefined"){ %>
            <div class="col-xs-12">
            <% } %>
              <% if(typeof(use_textarea) == "undefined"){ %>
               <div class="input-group" style="width:100%">
               


              <% } %>
                <<%= (typeof(use_textarea) == "undefined") ? "input type=\"text\"" : ("textarea style=\"height:" + ((typeof(textarea_height) == "undefined") ? 146 : textarea_height ) + "px\"") %>  class="form-control input_selector_string" id="<%= id %>" <%= (default_selector == "int") ? "style=\"display:none\"" : "" %> placeholder="<%= description %>" value="<%= (typeof(value_string) != "undefined") ? value_string : "" %>" />
                <input class="form-control input_selector_number" type="number" id="<%= id %>_number" <%= (default_selector != "int") ? "style=\"display:none\"" : "" %> placeholder="<%= description %>" value="<%= (typeof(value_number) != "undefined") ? value_number : 1%>" step="<%= (typeof(step_number) != "undefined") ? step_number : 1%>" min="<%= (typeof(min_number) != "undefined") ? min_number : 0%>" max="<%= (typeof(max_number) != "undefined") ? max_number : 10000%>" />
                

                <% if(typeof(variants) != "undefined" || typeof(disable_editor) == "undefined" || typeof(disable_resource) == "undefined" || typeof(disable_variable) == "undefined") { %>
                  <ul class="dropdown-menu input-field-dropdown dropdown-align dropdown-black">
                    <% if(typeof(variants) != "undefined") { %>
                      <% for(var i = 0;i<variants.length;i++) { %>
                        <li>
                          <a tabindex="-1" href="#" data-toggle="modal"  data-variant="<%= variants[i] %>" data-result="<%= id %>" class="variant" >
                            <span><%= variants[i] %></span>
                          </a>
                        </li>
                      <% } %>
                      <li class="divider"></li>
                    <% } %>

                    <% if(typeof(disable_editor) == "undefined") { %>
                      <li>
                        <a tabindex="-1" href="#" data-toggle="modal" data-result-target="#<%= id %>" class="edit" >
                          <i class="fa fa-circle" style="color:darkred" />
                            <span class="tr">Create value in visual constructor</span>
                        </a>
                      </li>
                    <% } %>
                    <% if(typeof(disable_resource) == "undefined") { %>
                      <li>
                        <a tabindex="-1" href="#" data-toggle="modal" data-result-target="#<%= id %>" class="res" >
                          <i class="fa fa-database" />
                            <span class="tr">Load from file, user input, database</span>
                        </a>
                      </li>
                    <% } %>
                    <% if(typeof(disable_variable) == "undefined") { %>
                      <li>
                        <a tabindex="-1" href="#" data-toggle="modal" data-result-target="#<%= id %>" class="var" >
                          <i class="fa fa-at" />
                            <span class="tr">Insert variable</span>
                        </a>
                      </li>
                    <% } %>
                  </ul>
                <% } %>

                <% if(typeof(use_textarea) == "undefined" && typeof(disable_label) == "undefined" && typeof(description) == "string" && description.length > 0){ %>
                  <span  tabindex="-1" class="input-group-addon input-description"><%= description %></span>
                <% } %>
                
                <div class="input-group-btn dropdown-input-type" <%= (typeof(disable_type_chooser) != "undefined") ? "style=\"display:none\"" : "" %>>
                  <button  tabindex="-1" type="button" class="btn btn-default dropdown-toggle dropdown-input-type" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="selector" data-selector-id="<%= id %>"><%= default_selector %></span> <span class="caret"></span></button>
                  <ul class="dropdown-menu dropdown-menu-right">
                    <% if(typeof(disable_string) == "undefined") { %>
                      <li><a class="string" class="tr">string</a></li>
                    <% } %>

                    <% if(typeof(disable_int) == "undefined") { %>
                      <li><a class="int">int</a></li>
                    <% } %>

                    <% if(typeof(disable_expression) == "undefined") { %>
                      <li><a class="expression">expression</a></li>
                    <% } %>
                  </ul>
                </div>

              <% if(typeof(use_textarea) == "undefined"){ %>

                </div>
              <% } %>
            <% if(typeof(dont_use_col) == "undefined"){ %>
              </div>
            <% } %>

            <% if(typeof(dont_use_top) == "undefined"){ %>
            </div>

        </form>
      </div>
      <% } %>
    </span>

  </script>

  <script type="text/template" id="special_buttons">
    <div class="col-xs-12">
        <button tabindex="-1" type="button" class="btn btn-default specialletter btn-xs">CONTROL</button>
        <button tabindex="-1" type="button" class="btn btn-default specialletter btn-xs">MENU</button>
        <button tabindex="-1" type="button" class="btn btn-default specialletter btn-xs">SHIFT</button>
        <button tabindex="-1" type="button" class="btn btn-default specialletter btn-xs">CANCEL</button>
        <button tabindex="-1" type="button" class="btn btn-default specialletter btn-xs">BACK</button>
        <button tabindex="-1" type="button" class="btn btn-default specialletter btn-xs">TAB</button>
        <button tabindex="-1" type="button" class="btn btn-default specialletter btn-xs">CLEAR</button>
        <button tabindex="-1" type="button" class="btn btn-default specialletter btn-xs">RETURN</button>
        <button tabindex="-1" type="button" class="btn btn-default specialletter btn-xs">CAPITAL</button>
        <button tabindex="-1" type="button" class="btn btn-default specialletter btn-xs">ESCAPE</button>
        <button tabindex="-1" type="button" class="btn btn-default specialletter btn-xs">PRIOR</button>
        <button tabindex="-1" type="button" class="btn btn-default specialletter btn-xs">NEXT</button>
        <button tabindex="-1" type="button" class="btn btn-default specialletter btn-xs">END</button>
        <button tabindex="-1" type="button" class="btn btn-default specialletter btn-xs">HOME</button>
        <button tabindex="-1" type="button" class="btn btn-default specialletter btn-xs">LEFT</button>
        <button tabindex="-1" type="button" class="btn btn-default specialletter btn-xs">UP</button>
        <button tabindex="-1" type="button" class="btn btn-default specialletter btn-xs">RIGHT</button>
        <button tabindex="-1" type="button" class="btn btn-default specialletter btn-xs">DOWN</button>
        <button tabindex="-1" type="button" class="btn btn-default specialletter btn-xs">SELECT</button>
        <button tabindex="-1" type="button" class="btn btn-default specialletter btn-xs">PRINT</button>
        <button tabindex="-1" type="button" class="btn btn-default specialletter btn-xs">EXECUTE</button>
        <button tabindex="-1" type="button" class="btn btn-default specialletter btn-xs">SNAPSHOT</button>
        <button tabindex="-1" type="button" class="btn btn-default specialletter btn-xs">INSERT</button>
        <button tabindex="-1" type="button" class="btn btn-default specialletter btn-xs">DELETE</button>
        <button tabindex="-1" type="button" class="btn btn-default specialletter btn-xs">MOUSESCROLLUP</button>
        <button tabindex="-1" type="button" class="btn btn-default specialletter btn-xs">MOUSESCROLLDOWN</button>
      </div>
  </script>


  <script type="text/template" id="load">
    <div class="container-fluid load">
      <%= _.template($('#input_constructor').html())({id:"LoadUrl", description:tr("Url to load"), default_selector: "string", disable_int:true}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", use_waiter:true,waiter_enabled: true,use_timeout: true, visible:true}) %>
  </script>


  <script type="text/template" id="break">
    <div class="container-fluid continue">
      <div class="tooltipinternal tr">Stop loop.</div>
      <%= _.template($('#back').html())({action:"executeandadd", visible:false}) %>
    </div>
  </script>

   <script type="text/template" id="continue">
    <div class="container-fluid continue">
      <div class="tooltipinternal tr">Start next loop iteration.</div>
      <%= _.template($('#back').html())({action:"executeandadd", visible:false}) %>
    </div>
  </script>

  <script type="text/template" id="success">
    <div class="container-fluid success">
      <%= _.template($('#input_constructor').html())({id:"SuccessMessage", description:tr("Success Message"), default_selector: "string", disable_int:true}) %>
      <div class="tooltipinternal tr">Finish thread with success result.</div>
      <%= _.template($('#back').html())({action:"executeandadd", visible:false}) %>
    </div>
  </script>

  <script type="text/template" id="fail">
    <div class="container-fluid fail">
     <%= _.template($('#input_constructor').html())({id:"FailMessage", description:tr("Fail Message"), default_selector: "string", disable_int:true}) %>
    </div>
     <div class="tooltipinternal tr">Finish thread with fail result.</div>
     <span data-preserve="true" data-preserve-type="check" data-preserve-id="Check">
         <input type="checkbox" id="Check"/> <label for="Check" class="tr">Dont restart thread.</label>
      </span>
     <%= _.template($('#back').html())({action:"executeandadd", visible:false}) %>

  </script>

  <script type="text/template" id="die">
    <div class="container-fluid fail">
     <%= _.template($('#input_constructor').html())({id:"FailMessage", description:tr("Fail Message"), default_selector: "string", disable_int:true}) %>
    </div>
     <div class="tooltipinternal tr">Finish whole script.</div>
     <span data-preserve="true" data-preserve-type="check" data-preserve-id="Check">
         <input type="checkbox" id="Check"/> <label for="Check" class="tr">Finish script instantly.</label>
      </span>
     <%= _.template($('#back').html())({action:"executeandadd", visible:false}) %>

  </script>

  <script type="text/template" id="label">
    <div class="container-fluid fail">
     <%= _.template($('#input_constructor').html())({id:"Label", description:tr("Label"), default_selector: "string", disable_int:true, disable_expression:true, disable_resource: true, disable_editor: true, disable_variable:true}) %>
    </div>
     <%= _.template($('#back').html())({action:"executeandadd", visible:false}) %>

  </script>

  <script type="text/template" id="goto">
    <div class="container-fluid executefunction">
      <div class="col-xs-12">
        <form class="form-horizontal" onsubmit="return false;">
          <div class="form-group">
            <div class="col-xs-5">
              <span data-preserve="true" data-preserve-type="text" data-preserve-id="LabelName">
                <input class="form-control label-input" type="text" id="LabelName" placeholder="Label">
              </span>
            </div>
            <button tabindex="-1" type="button" class="btn btn-default lab" data-toggle="modal" data-target="#LabelModal" data-result-target="#LabelName" ><i class="fa fa-tag"></i></button>
            <label class="col-xs-6 control-label tr" for="LabelName">Label</label>
          </div>
        </form>
      </div>
    </div>
    <div class="tooltipinternal tr">There are two types of goto: long and short. Short move is performed if goto and label are located inside same block (has one parent). This type of move preserves execution history and script continues afterward. In other cases long move is performed, which clears execution history. Long move case is perfect if you are jumping on script start, but if you move inside loop, you must use another move to leave it, otherwise thread will stop with success message.</div>

    <%= _.template($('#back').html())({action:"executeandadd", visible:false}) %>

  </script>

  <script type="text/template" id="custom">
    <div class="container-fluid custom">
      <%= _.template($('#input_constructor').html())({id:"Code", description:tr("Custom Code"), default_selector: "expression", disable_int:true, disable_editor:true, disable_string:true, use_textarea:true, size: 8, disable_type_chooser:true}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>


  <script type="text/template" id="template">
    <div class="container-fluid template">
      <%= _.template($('#input_constructor').html())({id:"Template", description:tr("Template"), default_selector: "expression", disable_int:true, disable_editor:true, disable_string:true, use_textarea:true, size: 8, disable_type_chooser:true,textarea_height:80}) %>
      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save Result"), default_variable: "TEMPLATE_RESULT"}) %>
      <span data-preserve="true" data-preserve-type="check" data-preserve-id="Check">
         <input type="checkbox" id="Check"/> <label for="Check" class="tr">Additional processing. Use this option if you want to load template from file or variable.</label>
      </span>
      <div class="tooltipinternal tr">Resolves template to variable. Can contain {{Resources}} and [[VARIABLES]] and spintax {hi|hello}.</div>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>


  <script type="text/template" id="replacestring">
    <div class="container-fluid replacestring">
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Original String"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#input_constructor').html())({id:"ReplaceFrom", description:tr("Replace From"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#input_constructor').html())({id:"ReplaceTo", description:tr("Replace To"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save Result"), default_variable: "REPLACE_RESULT"}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>


  <script type="text/template" id="randomstring">
    <div class="container-fluid randomstring">
      <%= _.template($('#input_constructor').html())({id:"AllowedChars", description:tr("Allowed Chars"), default_selector: "string", disable_int:true, value_string: "abcdefghijklmnopqrstuvwxyz0123456789"}) %>
      <%= _.template($('#input_constructor').html())({id:"Length", description:tr("Result String Length"), default_selector: "int", disable_string:true, value_number:10, min_number:1, max_number:999999}) %>
      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save Result"), default_variable: "RANDOM_STRING"}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="randomint">
    <div class="container-fluid randomint">
      <%= _.template($('#input_constructor').html())({id:"MinValue", description:tr("Minimum Value"), default_selector: "int", disable_string:true, value_number:0, min_number:-999999, max_number:999999}) %>
      <%= _.template($('#input_constructor').html())({id:"MaxValue", description:tr("Maximum Value"), default_selector: "int", disable_string:true, value_number:100, min_number:-999999, max_number:999999}) %>
      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save Result"), default_variable: "RANDOM_NUMBER"}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>


  <script type="text/template" id="waitload">
    <div class="container-fluid load">
      <%= _.template($('#input_constructor').html())({id:"Wait", description:tr("Wait until browser will load url"), default_selector: "string", disable_int:true}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd",use_timeout: true, visible:true}) %>
  </script>

  <script type="text/template" id="waiturl">
    <div class="container-fluid load">
      <%= _.template($('#input_constructor').html())({id:"Wait", description:tr("Wait address bar will contain url"), default_selector: "string", disable_int:true}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd",use_timeout: true, visible:true}) %>
  </script>

  <script type="text/template" id="waitcontent">
    <div class="container-fluid load">
      <%= _.template($('#input_constructor').html())({id:"Wait", description:tr("Wait until specific text will be present on page"), default_selector: "string", disable_int:true}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd",use_timeout: true, visible:true}) %>
  </script>

  <script type="text/template" id="waitcss">
    <div class="container-fluid load">
      <%= _.template($('#input_constructor').html())({id:"Wait", description:tr("Wait until specific css selector will return non empty result"), default_selector: "string", disable_int:true}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd",use_timeout: true, visible:true}) %>
  </script>

  <script type="text/template" id="waitfiledownload">
     <div class="container-fluid reset">
       <div class="tooltipinternal tr">Wait for the end of the current download.</div>
     </div>
     <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To save file name"), default_variable: "DOWNLOADED_FILE_PATH"}) %>
     <%= _.template($('#back').html())({action:"executeandadd",use_timeout: true, visible:true}) %>
  </script>

  



  <script type="text/template" id="executefunction">
    <div class="container-fluid executefunction">
      <div class="col-xs-12">
        <form class="form-horizontal">
          <div class="form-group">
            <div class="col-xs-5">
              <span data-preserve="true" data-preserve-type="text" data-preserve-id="FunctionName">
                <input class="form-control function-input" type="text" id="FunctionName" placeholder="Function name">
              </span>
            </div>
            <button tabindex="-1" type="button" class="btn btn-default func" data-toggle="modal" data-target="#FunctionModal" data-result-target="#FunctionName" ><i class="fa fa-dot-circle-o"></i></button>
            <label class="col-xs-6 control-label tr" for="FunctionName">Function name</label>
          </div>
        </form>
      </div>

    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:false}) %>
  </script>


  <script type="text/template" id="executefunctioninseveralthreads">
    <div class="container-fluid">
      <div class="col-xs-12">
        <form class="form-horizontal">
          <div class="form-group">
            <div class="col-xs-5">
              <span data-preserve="true" data-preserve-type="text" data-preserve-id="FunctionName">
                <input class="form-control function-input" type="text" id="FunctionName" placeholder="Function name">
              </span>
            </div>
            <button tabindex="-1" type="button" class="btn btn-default func" data-toggle="modal" data-target="#FunctionModal" data-result-target="#FunctionName" ><i class="fa fa-dot-circle-o"></i></button>
            <label class="col-xs-6 control-label tr" for="FunctionName">Function name</label>
          </div>
        </form>
      </div>

      <%= _.template($('#input_constructor').html())({id:"ThreadNumber", description:tr("Thread number"), default_selector: "int", disable_string:true, disable_string:true, min_number: 1, value_number:10}) %>
      <%= _.template($('#input_constructor').html())({id:"SuccessNumber", description:tr("Success number"), default_selector: "int", disable_string:true, disable_string:true, min_number: 1, value_number:100}) %>
      <%= _.template($('#input_constructor').html())({id:"FailNumber", description:tr("Fail number"), default_selector: "int", disable_string:true, disable_string:true, min_number: 1, value_number:100}) %>
      <div class="tooltipinternal tr text-danger">Data exchange can only be performed with global variables or resources.</div>


    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:false}) %>
  </script>


  <script type="text/template" id="setheader">
    <div class="container-fluid setheader">
      <%= _.template($('#input_constructor').html())({id:"Name", description:tr("Header Name"), default_selector: "string", disable_int:true, value_string: "User-Agent", variants: ["User-Agent","Accept-Language","Referer"], size: 3}) %>
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Header Value"), default_selector: "string", disable_int:true, value_string: "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:44.0) Gecko/20100101 Firefox/44.0"}) %>
      <%= _.template($('#targetfields').html())({}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", use_target:true, visible:true}) %>
  </script>

  <script type="text/template" id="solvecaptcha">
    <div class="container-fluid solvecaptcha">
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Captcha picture data encoded in base64"), default_selector: "expression", disable_int:true, disable_string:true}) %>
      <%= _.template($('#input_constructor').html())({id:"Method", description:tr("Solve Method"), default_selector: "string", disable_int:true, value_string: "manual", variants: ["manual","antigate","rucaptcha","2captcha","capmonster","dbc", "captchasniper"], size: 3}) %>
      <%= _.template($('#input_constructor').html())({id:"Antigate", description:tr("Antigate/Rucaptcha/2captcha/DBC Key. Can be blank"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#input_constructor').html())({id:"Server", description:tr("Server url. Can be blank"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save Result"), default_variable: "CAPTCHA_RESULT"}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd",use_timeout: true, visible:true}) %>
  </script>
  
  <script type="text/template" id="javascript">
      <div class="container-fluid javascript">
        <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save"), default_variable: "SAVED_SCRIPT_RESULT"}) %>
        <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Script Text"), default_selector: "string", disable_int:true}) %>
      </div>
      <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="onloadjavascript">
      <div class="container-fluid javascript">
        <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Script Text"), default_selector: "string", disable_int:true, disable_editor:true, use_textarea:true, size: 8, disable_type_chooser:true}) %>
        <%= _.template($('#targetfields').html())({}) %>
      </div>
      <%= _.template($('#back').html())({action:"executeandadd", use_target:true, visible:true}) %>
  </script>

  <script type="text/template" id="parseline">
    <div class="container-fluid parseline">
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Line"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#variable_constructor').html())({id:"VariablesList", description:tr("Variables To Save Result"), default_variable: "USERNAME,PASSWORD", append_mode:true}) %>
      <div class="tooltipinternal tr">Parse line which contains list of varibales. Example, parse line <i>email@gmail.com:mypass1</i> to variables USERNAME and PASSWORD.</div>
      <div class="tooltipinternal tr">Put variables in following format to Variables List field: USERNAME,PASSWORD</div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
    
  </script>

  <script type="text/template" id="reset">
      <div class="container-fluid reset">
        <div class="tooltipinternal tr">Clear all browser data.</div>
      </div>
      <span data-preserve="true" data-preserve-type="check" data-preserve-id="Check">
         <input type="checkbox" id="Check"/> <label for="Check" class="tr">Restart process</label>
       </span>
      <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="openfile">
    <div class="container-fluid openfile">
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("File path to set as result of open file dialog"), default_selector: "string", disable_int:true}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="promptresult">
    <div class="container-fluid promptresult">
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Prompt user input result"), default_selector: "string", disable_int:true}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="httpauth">
    <div class="container-fluid httpauth">
      <%= _.template($('#input_constructor').html())({id:"Login", description:tr("Http auth login"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#input_constructor').html())({id:"Password", description:tr("Http auth password"), default_selector: "string", disable_int:true}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="getcookiesforurl">
      <div class="container-fluid getcookiesforurl">
        <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Url"), default_selector: "string", disable_int:true}) %>
        <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save"), default_variable: "COOKIES_FOR_URL"}) %>
      </div>
      <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="savecookies">
    <div class="container-fluid savecookies">
          <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save"), default_variable: "SAVED_COOKIES"}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="restorecookies">
    <div class="container-fluid restorecookies">
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Cookies"), default_selector: "string", disable_int:true}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="scroll">
    <div class="container-fluid scroll">
      <%= _.template($('#input_constructor').html())({id:"X", description:tr("Scroll x position"), default_selector: "int", disable_string:true}) %>
      <%= _.template($('#input_constructor').html())({id:"Y", description:tr("Scroll y position"), default_selector: "int", disable_string:true}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", use_waiter:true, use_timeout: true, visible:true}) %>
  </script>

  <script type="text/template" id="html">
      <div class="container-fluid html">
        <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save"), default_variable: "SAVED_PAGE_HTML"}) %>
      </div>
      <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="renderscreen">
    <div class="container-fluid renderscreen">
      <%= _.template($('#input_constructor').html())({id:"X", description:"X", default_selector: "int", disable_string:true, value_number:0}) %>
      <%= _.template($('#input_constructor').html())({id:"Y", description:"Y", default_selector: "int", disable_string:true, value_number:0}) %>

      <%= _.template($('#input_constructor').html())({id:"Width", description:tr("Width"), default_selector: "int", disable_string:true, value_number:100}) %>
      <%= _.template($('#input_constructor').html())({id:"Height", description:tr("Height"), default_selector: "int", disable_string:true, value_number:100}) %>
 
      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable to save as base64 png"), default_variable: "RENDER_RESULT"}) %>

 
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

<script type="text/template" id="cachemaskallow">
    <div class="container-fluid cachemaskallow">
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Match"), default_selector: "string", disable_int:true, value_string: "*"}) %>
      <div class="tooltipinternal tr">Add page content to cache if url is matching. For example *.json - caches all json</div>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>
  
  <script type="text/template" id="cachemaskdeny">
    <div class="container-fluid cachemaskdeny">
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Match"), default_selector: "string", disable_int:true}) %>
      <div class="tooltipinternal tr">Do not add page content to cache if url is matching.</div>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="cachemaskclear">
    <div class="container-fluid cachemaskclear">
      <div class="tooltipinternal tr">Clear all cache masks.</div>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="restrictpopups">
    <div class="container-fluid cachemaskclear">
      <div class="tooltipinternal tr">Restrict all popups. You can restrict specific popup with Request Mask Deny action.</div>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="restrictdownloads">
    <div class="container-fluid cachemaskclear">
      <div class="tooltipinternal tr">Restrict all downloads. You can restrict specific download with Request Mask Deny action.</div>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="allowpopups">
    <div class="container-fluid cachemaskclear">
      <div class="tooltipinternal tr">Allow all popups. Revokes Allow popup action.</div>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="allowdownloads">
    <div class="container-fluid cachemaskclear">
      <div class="tooltipinternal tr">Allow all downloads. Revokes Allow downloads action.</div>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="requestmaskallow">
    <div class="container-fluid requestmaskallow">
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Match"), default_selector: "string", disable_int:true}) %>
      <div class="tooltipinternal tr">Allow load url if url is matching. By default every url is loaded</div>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="requestmaskdeny">
    <div class="container-fluid requestmaskdeny">
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Match"), default_selector: "string", disable_int:true}) %>
      <div class="tooltipinternal tr">Deny load url if url is matching. For example *.png disables loading png images.</div>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="requestmaskclear">
    <div class="container-fluid requestmaskclear">
      <div class="tooltipinternal tr">Clear all requests masks.</div>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="cleardata">
    <div class="container-fluid cleardata">
      <div class="tooltipinternal tr">Clear all cache masks.</div>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="clearmasks">
    <div class="container-fluid clearmasks">
      <div class="tooltipinternal tr">Clear info about all loaded urls.</div>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="loadcookiesfrombrowser">
    <div class="container-fluid">
      <div class="tooltipinternal tr">Load cookies from browser.</div>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="loadcookiesfromhttpclient">
    <div class="container-fluid">
      <div class="tooltipinternal tr">Load cookies from http client.</div>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="closebrowser">
    <div class="container-fluid">
      <div class="tooltipinternal tr">Close browser.</div>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="openbrowser">
    <div class="container-fluid">
      <div class="tooltipinternal tr">Open browser.</div>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="getstatus">
    <div class="container-fluid getstatus">
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Match"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save"), default_variable: "SAVED_STATUS"}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="isloaded">
    <div class="container-fluid isloaded">
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Match"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save"), default_variable: "SAVED_IS_LOADED"}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>
  
  <script type="text/template" id="getfromcache">
    <div class="container-fluid getfromcache">
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Match"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save"), default_variable: "SAVED_CACHE"}) %>
       <span data-preserve="true" data-preserve-type="check" data-preserve-id="Check">
         <input type="checkbox" id="Check"/> <label for="Check" class="tr">Encode in base64</label>
       </span>

      <div class="tooltipinternal tr">After execution variale will hold cached page content which matching url.</div>

    </div>
    <%= _.template($('#back').html())({action:"executeandadd", use_timeout: true, visible:true}) %>
  </script>
  
  <script type="text/template" id="result">
    <div class="container-fluid result">
       <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Result Data"), default_selector: "string", disable_int:true}) %>
       <div class="col-xs-12">
        <form class="form-horizontal">
          <div class="form-group">
            <div class="col-xs-2">
              <div class="input-group">
                <span data-preserve="true" data-preserve-type="select" data-preserve-id="Select">
                  <select class="form-control input-sm" id="Select" placeholder="Result">
                      <option value="1" selected="selected">1</option>
                      <option value="2">2</option>
                      <option value="3">3</option>
                      <option value="4">4</option>
                      <option value="5">5</option>
                      <option value="6">6</option>
                      <option value="7">7</option>
                      <option value="8">8</option>
                      <option value="9">9</option>
                  </select>
                </span>
              </div>
            </div>
            <label class="control-label text-right tr" style="padding-top:5px !important;">Result Placeholder</label>
          </div>
        </form>
      </div>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="timeout">
    <div class="container-fluid result">
       <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Timeout in milliseconds"), default_selector: "int", disable_string:true, value_number: 60000, min_number: 1000}) %>
       <div class="col-xs-12">
        <form class="form-horizontal">
          <div class="form-group">
            <div class="col-xs-2">
              <div class="input-group">
                <span data-preserve="true" data-preserve-type="select" data-preserve-id="Type">
                  <select class="form-control input-sm" id="Type" placeholder="Result">
                      <option value="general" selected="selected">General</option>
                      <option value="fullpageload">Full Page Load</option>
                      <option value="solver">Solver</option>
                  </select>
                </span>
              </div>
            </div>
            <label class="control-label text-right tr" style="padding-top:5px !important;">Timeout Type</label>
          </div>
        </form>
      </div>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="base64">
    <div class="container-fluid base64">
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Data"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save"), default_variable: "BASE64_ENCODING_RESULT"}) %>
      <div class="col-xs-12">
        <form class="form-horizontal">
          <div class="form-group">
            <div class="col-xs-2">
              <div class="input-group">
              <span data-preserve="true" data-preserve-type="select" data-preserve-id="Select">
                <select class="form-control input-sm" id="Select" placeholder="Is Encode">
                    <option value="encode" selected="selected" >encode</option>
                    <option value="decode" >decode</option>
                </select>
              </span>
              </div>
            </div>
            <label class="control-label text-right tr" style="padding-top:5px !important;">Encode or decode</label>
          </div>
        </form>
      </div>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

<script type="text/template" id="globalset">
    <div class="container-fluid globalset">
      <%= _.template($('#variable_constructor').html())({id:"Name", description:tr("Variable Name"), default_variable: "", disable_locals: true, enable_globals:true}) %>
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Value"), default_selector: "string"}) %>
      <div class="tooltipinternal tr">Global variables are availabe during whole script run.</div>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="globalget">
    <div class="container-fluid globalget">
      <%= _.template($('#input_constructor').html())({id:"Name", description:tr("Variable Name"), default_selector: "string", disable_int:true, disable_editor:true, disable_resource:true, disable_variable:true}) %>
      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save"), default_variable: "GLOBAL_VARIABLE_RESULT"}) %>
      <div class="tooltipinternal">Global variables are availabe during whole script run.</div>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="emailsettings">
    <div class="container-fluid emailsettings">
      <%= _.template($('#input_constructor').html())({id:"Host", description:tr("Imap Server Host"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#input_constructor').html())({id:"Port", description:tr("Port"), default_selector: "int", disable_string:true, value_number: 993}) %>
      <%= _.template($('#input_constructor').html())({id:"Username", description:tr("Username. Can be blank"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#input_constructor').html())({id:"Password", description:tr("Password. Can be blank"), default_selector: "string", disable_int:true}) %>
      <div class="col-xs-12">
        <form class="form-horizontal">
          <div class="form-group">
            <div class="col-xs-2">
              <div class="input-group">
              <span data-preserve="true" data-preserve-type="select" data-preserve-id="Select">
                <select class="form-control input-sm" id="Select" placeholder="Encryption">
                    <option value="ssl" selected="selected">ssl</option>
                    <option value="none">none</option>
                </select>
              </span>
              </div>
            </div>
            <label class="control-label text-right tr" style="padding-top:5px !important;">Encryption</label>
          </div>
        </form>
      </div>
      <%= _.template($('#input_constructor').html())({id:"Inbox", description:tr("Inbox name"), default_selector: "string", disable_int:true, value_string:"INBOX"}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="emailproxy">
    <div class="container-fluid" >
      <%= _.template($('#input_constructor').html())({id:"ProxyText", description:tr("Proxy String"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#input_constructor').html())({id:"ProxyType", description:tr("Proxy Type"), default_selector: "string", disable_int:true, value_string: "http", variants: ["http","socks5","auto"]}) %>
      <%= _.template($('#input_constructor').html())({id:"ProxyLogin", description:tr("Proxy Login. Can be blank."), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#input_constructor').html())({id:"ProxyPassword", description:tr("Proxy password. Can be blank."), default_selector: "string", disable_int:true}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="emaillength">
    <div class="container-fluid emaillength">
      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save"), default_variable: "SAVED_MAILBOX_LENGTH"}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd",use_timeout: true, visible:true}) %>
  </script>

  <script type="text/template" id="emailsearchfirst">
    <div class="container-fluid emailsearchfirst">
      <%= _.template($('#input_constructor').html())({id:"Sender", description:tr("Sender Query"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#input_constructor').html())({id:"Subject", description:tr("Subject Query"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#input_constructor').html())({id:"Body", description:tr("Body Query"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save"), default_variable: "MAIBOX_SEARCH_RESULT"}) %>
      <%= _.template($('#variable_constructor').html())({id:"VariablesList", description:tr("Variables To Save Links"), default_variable: "LINK1,LINK2,LINK3", append_mode:true}) %>
      <div class="tooltipinternal tr">Parse email and get link list. Put variables in following format to Variables To Save Links: LINK1,LINK2,LINK3</div>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd",use_timeout: true, visible:true}) %>
  </script>
<script type="text/template" id="emailsearchall">
    <div class="container-fluid emailsearchall">
      <%= _.template($('#input_constructor').html())({id:"Sender", description:tr("Sender Query"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#input_constructor').html())({id:"Subject", description:tr("Subject Query"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#input_constructor').html())({id:"Body", description:tr("Body Query"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save"), default_variable: "MAIBOX_SEARCH_RESULT"}) %>
   </div>
    <%= _.template($('#back').html())({action:"executeandadd",use_timeout: true, visible:true}) %>
  </script>

  <script type="text/template" id="emailpull">
    <div class="container-fluid emailpull">
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Message Id"), default_selector: "string", disable_int:true}) %>
      <div class="tooltipinternal tr">Use action 'Search First', if you want to get only one message.</div>

      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save"), default_variable: "MAIL_BODY"}) %>
      <%= _.template($('#variable_constructor').html())({id:"VariablesList", description:tr("Variables To Save Links"), default_variable: "LINK1,LINK2,LINK3", append_mode:true}) %>
      <div class="tooltipinternal tr">Parse email and get link list. Put variables in following format to Variables To Save Links: LINK1,LINK2,LINK3</div>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd",use_timeout: true, visible:true}) %>
  </script>

<script type="text/template" id="httpclientproxy">
    <div class="container-fluid" >
      <%= _.template($('#input_constructor').html())({id:"ProxyText", description:tr("Proxy String"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#input_constructor').html())({id:"ProxyType", description:tr("Proxy Type"), default_selector: "string", disable_int:true, value_string: "http", variants: ["http","socks5","auto"]}) %>
      <%= _.template($('#input_constructor').html())({id:"ProxyLogin", description:tr("Proxy Login. Can be blank."), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#input_constructor').html())({id:"ProxyPassword", description:tr("Proxy password. Can be blank."), default_selector: "string", disable_int:true}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>
<script type="text/template" id="httpclientreset">
    <div class="container-fluid httpclientreset">
      <div class="tooltipinternal tr">Clear all http client data.</div>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>
<script type="text/template" id="httpclientdownload">
    <div class="container-fluid httpclientdownload">
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Url"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#input_constructor').html())({id:"File", description:tr("File Path"), default_selector: "string", disable_int:true}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd",use_timeout: true, visible:true}) %>
  </script>
<script type="text/template" id="httpclientget">
    <div class="container-fluid httpclientget">
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Url"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#input_constructor').html())({id:"Method", description:tr("Method"), default_selector: "string", disable_int:true, value_string: "GET", variants:["GET","HEAD","DELETE","TRACE","OPTIONS"], size:3}) %>
      <span data-preserve="true" data-preserve-type="check" data-preserve-id="Check">
        <input type="checkbox" id="Check" checked="checked"/> <label for="Check" class="tr">Follow redirects</label>
      </span>

    </div>
    <%= _.template($('#back').html())({action:"executeandadd",use_timeout: true, visible:true}) %>
  </script>
  <script type="text/template" id="httpclientpost">
    <div class="container-fluid httpclientpost">
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Url"), default_selector: "string", disable_int:true}) %>
      
      <div class="col-xs-12">
       <form class="form-horizontal">
          <div class="form-group">
            <hr style="margin-top:5px;margin-bottom:5px"/>
            <span class="tr" style="margin-left:15px;">Post Data</span>:
            <hr style="margin-top:5px;margin-bottom:5px"/>
            <%= _.template($('#input_constructor').html())({id:"PostName", description:tr("Request Parameter Name"), default_selector: "string", disable_int:true, dont_use_top: true }) %>
          </div>
        </form>
      </div>

      <div class="col-xs-12">
       <form class="form-horizontal">
          <div class="form-group">
            <%= _.template($('#input_constructor').html())({id:"PostValue", description:tr("Request Parameter Value"), default_selector: "string", disable_int:true, dont_use_top: true }) %>
          </div>
        </form>
      </div>


      <div class="col-xs-12">
       <form class="form-horizontal">
          <div class="form-group">
            <button tabindex="-1" type="button" class="btn btn-default addtopost" > + <span class="tr">Add</span></button>
            <button tabindex="-1" type="button" class="btn btn-default addtopostfile" > + <span class="tr">Add As File</span></button>
            <button tabindex="-1" type="button" class="btn btn-default addtopostbase64" > + <span class="tr">Add As Base64 Data</span></button>
            <span class="tr">Use these buttons to fill POST data</span>
          </div>
        </form>
      </div>

      <%= _.template($('#input_constructor').html())({id:"PostDataArray", description:tr("Post Data"), default_selector: "expression", disable_int:true, disable_string:true}) %>

      
      <div class="col-xs-12">
       <form class="form-horizontal">
          <div class="form-group">
            <hr style="margin-top:5px;margin-bottom:5px"/>
            <span class="tr" style="margin-left:15px;">Additional Parameters</span>:
            <hr style="margin-top:5px;margin-bottom:5px"/>
          </div>
        </form>
      </div>
      

      <%= _.template($('#input_constructor').html())({id:"Encoding", description:tr("Encoding"), default_selector: "string", disable_int:true, value_string: "UTF-8"}) %>

      
      <%= _.template($('#input_constructor').html())({id:"Method", description:tr("Method"), default_selector: "string", disable_int:true, value_string: "POST", variants:["POST","PUT","PATCH"], size:3}) %>

      <span data-preserve="true" data-preserve-type="check" data-preserve-id="Check">
        <input type="checkbox" id="Check" checked="checked"/> <label for="Check" class="tr">Follow redirects</label>
      </span>
      
      <%= _.template($('#input_constructor').html())({id:"ContentType", description:tr("Content Type"), default_selector: "string", disable_int:true, value_string: "urlencode", variants:["urlencode","multipart","json"], size:3}) %>      

    </div>
    <%= _.template($('#back').html())({action:"executeandadd",use_timeout: true, visible:true}) %>
  </script>
  <script type="text/template" id="httpclienturl">
    <div class="container-fluid httpclienturl">
      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save"), default_variable: "SAVED_URL"}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="httpclientcontent">
    <div class="container-fluid httpclientcontent">
      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save"), default_variable: "SAVED_CONTENT"}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="httpclientstatus">
    <div class="container-fluid httpclientstatus">
      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save"), default_variable: "SAVED_STATUS"}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="httpclientgetheader">
    <div class="container-fluid httpclientgetheader">
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Header Name"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save"), default_variable: "SAVED_HEADER"}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="httpclientsetheader">
    <div class="container-fluid httpclientsetheader">
      <%= _.template($('#input_constructor').html())({id:"Name", description:tr("Header Name"), default_selector: "string", disable_int:true, value_string: "User-Agent", variants: ["User-Agent","Accept-Language"], size: 3}) %>
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Header Value"), default_selector: "string", disable_int:true, value_string: "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:44.0) Gecko/20100101 Firefox/44.0"}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="httpclientclearheader">
    <div class="container-fluid httpclientclearheader">
      <div class="tooltipinternal tr">Clear all headers.</div>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="httpclientgetcookiesforurl">
    <div class="container-fluid httpclientgetcookiesforurl">
        <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Url"), default_selector: "string", disable_int:true}) %>
        <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save"), default_variable: "COOKIES_FOR_URL"}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="httpclientsavecookies">
    <div class="container-fluid httpclientsavecookies">
      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save"), default_variable: "SAVED_COOKIES"}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="httpclientrestorecookies">
    <div class="container-fluid httpclientrestorecookies">
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Cookies"), default_selector: "string", disable_int:true}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="httpclientfailonerror">
    <div class="container-fluid httpclientfailonerror">
      <%= _.template($('#input_constructor').html())({id:"SetFailed", description:tr("Set Fail On Error"), default_selector: "string", disable_int:true, value_string: "fail", variants: ["fail","continue"], size: 5}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="httpclientiserror">
    <div class="container-fluid httpclientiserror">
       <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save"), default_variable: "HTTP_CLIENT_WAS_ERROR"}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="httpclientgeterrorstring">
    <div class="container-fluid httpclientgeterrorstring">
      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save"), default_variable: "HTTP_CLIENT_ERROR_STRING"}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="httpclientxpathxml">
    <div class="container-fluid httpclientxpath">
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Xpath Query"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save"), default_variable: "XPATH_XML"}) %>
      <span data-preserve="true" data-preserve-type="check" data-preserve-id="Check">
        <input type="checkbox" id="Check" checked="checked"/> <label for="Check" class="tr">Fail on error</label>
      </span>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="httpclientxpathxmllist">
    <div class="container-fluid httpclientxpath">
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Xpath Query"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save"), default_variable: "XPATH_XML_LIST"}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>
  
  <script type="text/template" id="httpclientxpathtext">
    <div class="container-fluid httpclientxpath">
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Xpath Query"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save"), default_variable: "XPATH_TEXT"}) %>
      <span data-preserve="true" data-preserve-type="check" data-preserve-id="Check">
        <input type="checkbox" id="Check" checked="checked"/> <label for="Check" class="tr">Fail on error</label>
      </span>


    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>


  <script type="text/template" id="httpclientxpathtextlist">
    <div class="container-fluid httpclientxpath">
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Xpath Query"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save"), default_variable: "XPATH_TEXT_LIST"}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>
  
  <script type="text/template" id="httpclientxpathcount">
    <div class="container-fluid httpclientxpath">
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Xpath Query"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save"), default_variable: "XPATH_COUNT"}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>
  
  <script type="text/template" id="httpclientxpathexists">
    <div class="container-fluid httpclientxpath">
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Xpath Query"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save"), default_variable: "XPATH_EXISTS"}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="if">
    <div class="container-fluid if">
      <%= _.template($('#input_constructor').html())({id:"IfExpression", description:tr("If expression"), default_selector: "expression", disable_int:true, disable_string:true}) %>
      <span data-preserve="true" data-preserve-type="check" data-preserve-id="IfElse">
        <input type="checkbox" id="IfElse"/> <label for="IfElse" class="tr">Add else block</label>
      </span>

    </div>
    <%= _.template($('#back').html())({action:"add", visible:false}) %>
  </script>

  <script type="text/template" id="while">
    <div class="container-fluid while">
      <%= _.template($('#input_constructor').html())({id:"WhileExpression", description:tr("While expression"), default_selector: "expression", disable_int:true, disable_string:true}) %>
    </div>
    <%= _.template($('#back').html())({action:"add", visible:false}) %>
  </script>

  <script type="text/template" id="for">
    <div class="container-fluid for">
      <%= _.template($('#input_constructor').html())({id:"ForFrom", description:tr("For from value"), default_selector: "expression", disable_string:true}) %>
      <%= _.template($('#input_constructor').html())({id:"ForTo", description:tr("For to value"), default_selector: "expression", disable_string:true}) %>
    </div>
    <%= _.template($('#back').html())({action:"add", visible:false}) %>
  </script>


  <script type="text/template" id="ignoreerrors">
    <div class="container-fluid ignoreerrors">
    </div>
    <div class="tooltipinternal tr">If error will occur during ignore error block, it will be ignored and execution will continue on next after block instruction.</div>

    <%= _.template($('#back').html())({action:"add", visible:false}) %>
  </script>

  <script type="text/template" id="foreach">
    <div class="container-fluid foreach">
      <%= _.template($('#input_constructor').html())({id:"ForArray", description:tr("Foreach Array"), default_selector: "expression", disable_string:true, disable_int:true}) %>
    </div>
    <%= _.template($('#back').html())({action:"add", visible:false}) %>
  </script>

  <script type="text/template" id="sleep">
    <div class="container-fluid sleep">
      <span id="sleeprandomspan" style="display:none">
        <%= _.template($('#input_constructor').html())({id:"sleepfrom", description:tr("Sleep from value in milliseconds"), default_selector: "int", disable_string:true, min_number: 100, value_number: 1000,max_number: 99999999}) %>
        <%= _.template($('#input_constructor').html())({id:"sleepto", description:tr("Sleep to value in milliseconds"), default_selector: "int", disable_string:true, min_number: 100, value_number: 1000,max_number: 99999999}) %>
      </span>
      <span id="sleepspan">
        <%= _.template($('#input_constructor').html())({id:"sleepfromto", description:tr("Sleep value in milliseconds"), default_selector: "int", disable_string:true, min_number: 100, value_number: 1000}) %>
      </span>
      <span data-preserve="true" data-preserve-type="check" data-preserve-id="sleeprandom">
        <input type="checkbox" class="groupselector" data-checked-group-id="sleeprandomspan" data-unchecked-group-id="sleepspan" id="sleeprandom" style="margin-left:20px"/> <label for="sleeprandom" class="tr">Sleep random time</label>
      </span>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="setvariable">
    <div class="container-fluid setvariable">
      <%= _.template($('#variable_constructor').html())({id:"SetVariableName", description:tr("Name of variable"), default_variable: "NEW_VARIABLE"}) %>
      <%= _.template($('#input_constructor').html())({id:"SetVariableValue", description:tr("Value of variable"), default_selector: "string"}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>


  <script type="text/template" id="incvariable">
    <div class="container-fluid setvariable">
      <%= _.template($('#variable_constructor').html())({id:"SetVariableName", description:tr("Name of variable"), default_variable: ""}) %>
      <%= _.template($('#input_constructor').html())({id:"IncVariableValue", description:tr("Increase variable value"), default_selector: "int", min_number: -9999999, value_number: 1}) %>
      
    </div>
    <div class="tooltipinternal tr">This means [[VARIABLE]] = [[VARIABLE]] + num</div>

    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>


  <script type="text/template" id="incglobalvariable">
    <div class="container-fluid setvariable">
      <%= _.template($('#variable_constructor').html())({id:"SetVariableName", description:tr("Name of variable"), default_variable: "", enable_globals:true, disable_locals: true}) %>
      <%= _.template($('#input_constructor').html())({id:"IncVariableValue", description:tr("Increase variable value"), default_selector: "int", min_number: -9999999, value_number: 1}) %>
      
    </div>
    <div class="tooltipinternal tr">This means [[VARIABLE]] = [[VARIABLE]] + num</div>

    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="url">
    <div class="container-fluid url">
      <%= _.template($('#variable_constructor').html())({id:"SaveUrl", description:tr("Variable To Save"), default_variable: "CURRENT_URL"}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="xml">
    <div class="container-fluid xml">
      <%= _.template($('#path').html())({selector:selector}) %>
      <%= _.template($('#variable_constructor').html())({id:"SaveXml", description:tr("Variable To Save"), default_variable: "SAVED_XML"}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true,use_timeout: true, name: tr("Get Element Content")}) %>
  </script>

  <script type="text/template" id="coordinates">
    <div class="container-fluid">
      <%= _.template($('#path').html())({selector:selector}) %>
      <%= _.template($('#variable_constructor').html())({id:"X", description:tr("X"), default_variable: "X"}) %>
      <%= _.template($('#variable_constructor').html())({id:"Y", description:tr("Y"), default_variable: "Y"}) %>
      <%= _.template($('#variable_constructor').html())({id:"Width", description:tr("Width"), default_variable: "Width"}) %>
      <%= _.template($('#variable_constructor').html())({id:"Height", description:tr("Heigth"), default_variable: "Height"}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true,use_timeout: true}) %>
  </script>

  <script type="text/template" id="script">
    <div class="container-fluid script">
      <%= _.template($('#path').html())({selector:selector}) %>
      <%= _.template($('#variable_constructor').html())({id:"SaveScript", description:tr("Variable To Save"), default_variable: "SAVED_SCRIPT_RESULT"}) %>
      <%= _.template($('#input_constructor').html())({id:"ScriptValue", description:tr("Script Text"), default_selector: "string", disable_int:true}) %>
      <div class="tooltipinternal tr">Use self variable, which is point to selected element.</div>

    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true,use_timeout: true, name: tr("Execute Javascript On Element")}) %>
  </script>

  <script type="text/template" id="text">
    <div class="container-fluid text">
      <%= _.template($('#path').html())({selector:selector}) %>
      <%= _.template($('#variable_constructor').html())({id:"SaveText", description:tr("Variable To Save"), default_variable: "SAVED_TEXT"}) %>
    </div>

    <%= _.template($('#back').html())({action:"executeandadd", visible:true,use_timeout: true, name: tr("Get Element Text")}) %>
  </script>

  <script type="text/template" id="clickelement">
    <div class="container-fluid clickelement">
      <%= _.template($('#path').html())({selector:selector}) %>
      <span data-preserve="true" data-preserve-type="check" data-preserve-id="Check" class="disable-if-find-by-image">
        <input type="checkbox" id="Check"/> <label for="Check" class="tr">Disable mouse emulation.</label>
      </span>
    </div>
    
    <%= _.template($('#back').html())({action:"executeandadd", use_waiter:true,use_timeout: true, visible:true, name: tr("Click On Element")}) %>
  </script>

  <script type="text/template" id="moveelement">
    <div class="container-fluid moveelement">
      <%= _.template($('#path').html())({selector:selector}) %>
      <div class="tooltipinternal tr">Move mouse pointer on element.</div>
    </div>
    <%= _.template($('#movefields').html())({}) %>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true,use_timeout: true, use_move: true, name: tr("Move On Element")}) %>
  </script>

  <script type="text/template" id="mousesettings">
    <div class="container-fluid dragelement">
      <%= _.template($('#input_constructor').html())({id:"Speed", description:tr("Speed"), default_selector: "expression", disable_int:true, disable_string:true, value_string: "100"}) %>
      <%= _.template($('#input_constructor').html())({id:"Gravity", description:tr("Gravity"), default_selector: "expression", disable_int:true, disable_string:true, value_string: "6"}) %>
      <%= _.template($('#input_constructor').html())({id:"Deviation", description:tr("Deviation"), default_selector: "expression", disable_int:true, disable_string:true, value_string: "2.5"}) %>
    </div>

    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="browsersettings">
    <div class="container-fluid">
      <%= _.template($('#input_constructor').html())({id:"UseFlash", description:tr("Enable Flash"), default_selector: "string", disable_int:true, value_string: "", variants: ["true", "false"]}) %>
      <%= _.template($('#input_constructor').html())({id:"IsSafe", description:tr("Disable webrtc and canvas"), default_selector: "string", disable_int:true, value_string: "", variants: ["true", "false"]}) %>
      <%= _.template($('#input_constructor').html())({id:"SkipFrames", description:tr("Number of frames to skip in run mode"), default_selector: "int", disable_string:true, value_number: 0}) %>
      <%= _.template($('#input_constructor').html())({id:"EncodeUtf8", description:tr("Force UTF-8 Encoding"), default_selector: "string", disable_int:true, value_string: "", variants: ["true", "false"]}) %>
      <%= _.template($('#input_constructor').html())({id:"RefreshConnections", description:tr("Proxies reconnect"), default_selector: "string", disable_int:true, value_string: "", variants: ["true", "false"]}) %>

      <div class="tooltipinternal tr">Empty string or 0 means, that value wont be changed. "Enable Flash" and "Disable webrtc and canvas" options will restart browser process and thereby reset all settings(proxies, headers, etc), so the best place to use this action is thread start. If you want to change settings for every thread, it is better to use settings tab.</div>

    </div>

    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="dragelement">
    <div class="container-fluid dragelement">
      <%= _.template($('#path').html())({selector:selector}) %>
    </div>
    <%= _.template($('#movefields').html())({}) %>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true,use_timeout: true, use_move: true, name: tr("Drag On Element")}) %>
  </script>


  <script type="text/template" id="dropelement">
    <div class="container-fluid dropelement">
      <%= _.template($('#path').html())({selector:selector}) %>

    </div>
    <%= _.template($('#movefields').html())({}) %>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true,use_timeout: true, use_move: true, name: tr("Drop On Element")}) %>
  </script>

  <script type="text/template" id="moveandclickelement">
    <div class="container-fluid moveandclickelement">
      <%= _.template($('#path').html())({selector:selector}) %>

      <span data-preserve="true" data-preserve-type="check" data-preserve-id="Check" class="disable-if-find-by-image">
        <input type="checkbox" id="Check"/> <label for="Check" class="tr">Disable mouse emulation.</label>
      </span>
    </div>
    <%= _.template($('#movefields').html())({}) %>
    <%= _.template($('#back').html())({action:"executeandadd", use_waiter:true,use_timeout: true, use_move:true, visible:true, name: tr("Move And Click On Element")}) %>
  </script>

  <script type="text/template" id="clear">
    <div class="container-fluid clear">
      <%= _.template($('#path').html())({selector:selector}) %>

      <div class="tooltipinternal tr">Clear edit. Works only on edit.</div>
    </div>
    <%= _.template($('#movefields').html())({}) %>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true,use_timeout: true, use_move: true, name: tr("Clear Edit")}) %>
  </script>

  <script type="text/template" id="typeelement">
    <div class="container-fluid typeelement">
      <%= _.template($('#path').html())({selector:selector}) %>

      <%= _.template($('#input_constructor').html())({id:"TypeData", description:tr("Text to type"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#input_constructor').html())({id:"TypeInterval", description:tr("Interval in milliseconds"), default_selector: "int", disable_string:true, value_number: 100, step_number: 100, min_number: 0, max_number:10000}) %>

      <%= _.template($('#special_buttons').html())({}) %>
      <span data-preserve="true" data-preserve-type="check" data-preserve-id="Check" class="disable-if-find-by-image">
         <input type="checkbox" id="Check"/> <label for="Check" class="tr">Disable mouse and keyboard emulation.</label>
      </span>
    </div>
    <%= _.template($('#movefields').html())({}) %>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true,use_timeout: true, use_waiter:true, use_move: true, name: tr("Type Text")}) %>
  </script>

  <script type="text/template" id="exist">
    <div class="container-fluid exist">
      <%= _.template($('#path').html())({selector:selector, hide_options:true, waitelement: false, failaction: false}) %>

      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save"), default_variable: "IS_EXISTS"}) %>
      <span data-preserve="true" data-preserve-type="check" data-preserve-id="Check" class="disable-if-find-by-image">
        <input type="checkbox" id="Check"/> <label for="Check" class="tr">Also check if visible on a screen</label>
      </span>

    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true, name: tr("Is Element Exists")}) %>
  </script>

  <script type="text/template" id="style">
    <div class="container-fluid style">
      <%= _.template($('#path').html())({selector:selector}) %>

      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save"), default_variable: "SAVED_STYLE"}) %>
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Style To Check"), default_selector: "string", disable_int:true}) %>
     <div class="tooltipinternal tr">Get element style. Use "display" to check if element is visible</div>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true, use_timeout:true, name: tr("Get Element Style")}) %>
  </script>

  <script type="text/template" id="check">
    <div class="container-fluid check">
      <%= _.template($('#path').html())({selector:selector}) %>

      <div class="tooltipinternal tr">Check cehckbox. Works only on checkboxes.</div>
    </div>
    <%= _.template($('#movefields').html())({}) %>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true,use_timeout: true, use_move: true, name: tr("Set Checkbox")}) %>
  </script>

  <script type="text/template" id="waitfullload">
    <div class="container-fluid waitfullload">
      <div class="tooltipinternal tr">Wait until full page load.</div>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", use_timeout: true, visible:true}) %>
  </script>

  <script type="text/template" id="waitelement">
    <span class="path2">
      <div class="container-fluid waitelement">
       <%= _.template($('#path').html())({selector:selector, disable_options:true}) %>
       <div class="tooltipinternal tr">Wait while matching query element exists on page.</div>
        <span data-preserve="true" data-preserve-type="check" data-preserve-id="Check" class="disable-if-find-by-image">
          <input type="checkbox" id="Check"/> <label for="Check" class="tr">Also check if visible on a screen</label>
        </span>
      </div>
      <%= _.template($('#back').html())({action:"executeandadd", visible:true,use_timeout: true, name: tr("Wait While Element Exists")}) %>
    </span>
  </script>

  <script type="text/template" id="focus">
    <div class="container-fluid focus">
      <%= _.template($('#path').html())({selector:selector}) %>

      <div class="tooltipinternal tr">Scroll to element.</div>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true,use_timeout: true, name: tr("Scroll To Element")}) %>
  </script>

  <script type="text/template" id="set">
    <div class="container-fluid set">
      <%= _.template($('#path').html())({selector:selector}) %>
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Set String"), default_selector: "string", disable_int:true}) %>
      <div class="tooltipinternal tr">Set combobox value to desired string. Works only on comboboxes.</div>
    </div>

    <%= _.template($('#back').html())({action:"executeandadd", visible:true,use_timeout: true, name: tr("Set Combobox Value")}) %>
  </script>

  <script type="text/template" id="set_integer">
    <div class="container-fluid set_integer">
      <%= _.template($('#path').html())({selector:selector}) %>
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Set Index"), default_selector: "int", disable_string:true}) %>
      <div class="tooltipinternal tr">Set combobox index to desired int. Works only on comboboxes.</div>
    </div>
    
    <%= _.template($('#back').html())({action:"executeandadd", visible:true,use_timeout: true, name: tr("Set Combobox Index")}) %>
  </script>

  <script type="text/template" id="set_random">
    <div class="container-fluid set_random">
      <%= _.template($('#path').html())({selector:selector}) %>
      <div class="tooltipinternal tr">Set combobox index to random int. Works only on comboboxes.</div>
    </div>
    
    <%= _.template($('#back').html())({action:"executeandadd", visible:true,use_timeout: true, name: tr("Set Combobox To Random")}) %>
  </script>

  <script type="text/template" id="attr">
    <div class="container-fluid attr">
      <%= _.template($('#path').html())({selector:selector}) %>
      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save"), default_variable: "SAVED_ATTRIBUTE"}) %>
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Attribute Name"), default_selector: "string", disable_int:true}) %>
    </div>
    
    <%= _.template($('#back').html())({action:"executeandadd", visible:true, use_timeout:true, name: tr("Get Element Attribute")}) %>
  </script>

  <script type="text/template" id="set_attr">
    <div class="container-fluid attr">
      <%= _.template($('#path').html())({selector:selector}) %>
      <%= _.template($('#input_constructor').html())({id:"Name", description:tr("Attribute Name"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#input_constructor').html())({id:"Value", description:tr("Attribute Value"), default_selector: "string", disable_int:true}) %>

      <div class="tooltipinternal tr">Set element attribute.</div>
    </div>
    
    <%= _.template($('#back').html())({action:"executeandadd", visible:true, use_timeout:true, name: tr("Set Element Attribute")}) %>
  </script>

  <script type="text/template" id="captcha">
    <div class="container-fluid captcha">
      <%= _.template($('#path').html())({selector:selector}) %>
      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save"), default_variable: "CAPTCHA_RESULT"}) %>
      <%= _.template($('#input_constructor').html())({id:"Method", description:tr("Solve Method"), default_selector: "string", disable_int:true, value_string: "manual", variants: ["manual","antigate","rucaptcha","2captcha","capmonster","dbc","captchasniper"], size: 3}) %>
      <%= _.template($('#input_constructor').html())({id:"Antigate", description:tr("Antigate/Rucaptcha/2captcha/DBC Key. Can be blank"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#input_constructor').html())({id:"Server", description:tr("Server url. Can be blank"), default_selector: "string", disable_int:true}) %>
    </div>
    
    <%= _.template($('#back').html())({action:"executeandadd", visible:true,use_timeout: true, name: tr("Solve Captcha")}) %>
  </script>

  <script type="text/template" id="screenshot">
    <div class="container-fluid">
      <%= _.template($('#path').html())({selector:selector}) %>
      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable to save screenshot as base64"), default_variable: "SCREENSHOT_BASE64"}) %>
    </div>
    
    <%= _.template($('#back').html())({action:"executeandadd", visible:true,use_timeout: true}) %>
  </script>


  <script type="text/template" id="length">
    <span class="path2">

    <div class="container-fluid length">
      <%= _.template($('#variable_constructor').html())({id:"Save", description:tr("Variable To Save"), default_variable: "ELEMENT_LENGTH"}) %>

      <%= _.template($('#path').html())({selector:selector, disable_options:true}) %>

      <div class="tooltipinternal tr">Get elements number matching query.</div>
    </div>
    </span>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true, name: tr("Get Element Count")}) %>

  </script>

  <script type="text/template" id="loopelement">
    <span class="path2">

    <div class="container-fluid loopelement">
      <%= _.template($('#path').html())({selector:selector}) %>
      <div class="tooltipinternal tr">Foreach element, which matching query.</div>
    </div>
    </span>
    <%= _.template($('#back').html())({action:"executeandadd", visible:false,use_timeout: true, name: tr("Start Loop")}) %>
  </script>

  <script type="text/template" id="move">
    <div class="container-fluid move">
      <%= _.template($('#input_constructor').html())({id:"MoveX", description:tr("Move x position"), default_selector: "int", disable_string:true, value_number: model['x']}) %>
      <%= _.template($('#input_constructor').html())({id:"MoveY", description:tr("Move y position"), default_selector: "int", disable_string:true, value_number: model['y']}) %>
    </div>
    <%= _.template($('#movefields').html())({}) %>

    <%= _.template($('#back').html())({action:"executeandadd", visible:true, use_move: true, name: tr("Move")}) %>
  </script>

  <script type="text/template" id="click">
    <div class="container-fluid click">
      <%= _.template($('#input_constructor').html())({id:"ClickX", description:tr("Click x position"), default_selector: "int", disable_string:true, value_number: model['x']}) %>
      <%= _.template($('#input_constructor').html())({id:"ClickY", description:tr("Click y position"), default_selector: "int", disable_string:true, value_number: model['y']}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", use_waiter:true,use_timeout:true, visible:true, name: tr("Click")}) %>
  </script>

  <script type="text/template" id="drag">
    <div class="container-fluid move">
      <%= _.template($('#input_constructor').html())({id:"X", description:tr("Drag x position"), default_selector: "int", disable_string:true, value_number: model['x']}) %>
      <%= _.template($('#input_constructor').html())({id:"Y", description:tr("Drop y position"), default_selector: "int", disable_string:true, value_number: model['y']}) %>
    </div>
    <%= _.template($('#movefields').html())({}) %>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true, use_move: true, name: tr("Drag")}) %>
  </script>

  <script type="text/template" id="drop">
    <div class="container-fluid move">
      <%= _.template($('#input_constructor').html())({id:"X", description:tr("Drop x position"), default_selector: "int", disable_string:true, value_number: model['x']}) %>
      <%= _.template($('#input_constructor').html())({id:"Y", description:tr("Drop y position"), default_selector: "int", disable_string:true, value_number: model['y']}) %>
    </div>
    <%= _.template($('#movefields').html())({}) %>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true, use_move: true, name: tr("Drop")}) %>
  </script>

  <script type="text/template" id="addtab">
    <div class="container-fluid addtab">
      <%= _.template($('#input_constructor').html())({id:"Url", description:tr("Url"), default_selector: "string", disable_int:true}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", use_waiter:true, waiter_enabled: true, use_timeout:true, visible:true, name: tr("Add Tab")}) %>
  </script>

  <script type="text/template" id="selecttab">
    <div class="container-fluid selecttab">
      <%= _.template($('#input_constructor').html())({id:"Index", description:tr("Tab Index"), default_selector: "int", disable_string:true, value_number: model['index'], min_number:0, max_number:999999}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true, name: tr("Select Tab")}) %>
  </script>

  <script type="text/template" id="closetab">
    <div class="container-fluid closetab">
      <%= _.template($('#input_constructor').html())({id:"Index", description:tr("Tab Index"), default_selector: "int", disable_string:true, value_number: model['index'], min_number:1, max_number:999999}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd",visible:true, name: tr("Close Tab")}) %>
  </script>

  <script type="text/template" id="threadnumber">
    <div class="container-fluid threadnumber">
      <%= _.template($('#input_constructor').html())({id:"ThreadNumber", description:tr("Thread number"), default_selector: "int", disable_string:true, disable_string:true, disable_variable:true, min_number: 1}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:false}) %>
  </script>

  <script type="text/template" id="failnumber">
    <div class="container-fluid failnumber">
      <%= _.template($('#input_constructor').html())({id:"FailNumber", description:tr("Fail number"), default_selector: "int", disable_string:true, disable_string:true, disable_variable:true, min_number: 1}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:false}) %>
  </script>

  <script type="text/template" id="successnumber">
    <div class="container-fluid successnumber">
      <%= _.template($('#input_constructor').html())({id:"SuccessNumber", description:tr("Success number"), default_selector: "int", disable_string:true, disable_string:true, disable_variable:true, min_number: 1}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:false}) %>
  </script>

  <script type="text/template" id="moveandclick">
    <div class="container-fluid moveandclick">
      <%= _.template($('#input_constructor').html())({id:"X", description:tr("Move and click x position"), default_selector: "int", disable_string:true, value_number: model['x']}) %>
      <%= _.template($('#input_constructor').html())({id:"Y", description:tr("Move and click y position"), default_selector: "int", disable_string:true, value_number: model['y']}) %>
    </div>
    <%= _.template($('#movefields').html())({}) %>

    <%= _.template($('#back').html())({action:"executeandadd", use_waiter:true,use_timeout: true, use_move: true, visible:true, name: tr("Move And Click")}) %>
  </script>

  <script type="text/template" id="type">
    <div class="container-fluid type">
      <%= _.template($('#input_constructor').html())({id:"TypeData", description:tr("Text to type"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#input_constructor').html())({id:"TypeInterval", description:tr("Interval in milliseconds"), default_selector: "int", disable_string:true, value_number: 100, step_number: 100, min_number: 0, max_number:10000}) %>
      <%= _.template($('#special_buttons').html())({}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true, use_waiter:true, use_timeout: true, name: tr("Type Text")}) %>
  </script>

  <script type="text/template" id="resize">
    <div class="container-fluid resize">
      <%= _.template($('#input_constructor').html())({id:"ResizeX", description:tr("Width"), default_selector: "int", disable_string:true,value_number: 1024, step_number: 1, min_number: 100, max_number:10000}) %>
      <%= _.template($('#input_constructor').html())({id:"ResizeY", description:tr("Height"), default_selector: "int", disable_string:true,value_number: 768, step_number: 1, min_number: 100, max_number:10000}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:false}) %>
  </script>

  <script type="text/template" id="proxy">
    <div class="container-fluid" >
      <%= _.template($('#input_constructor').html())({id:"ProxyText", description:tr("Proxy String"), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#input_constructor').html())({id:"ProxyType", description:tr("Proxy Type"), default_selector: "string", disable_int:true, value_string: "http", variants: ["http","socks5","auto"]}) %>
      <%= _.template($('#input_constructor').html())({id:"ProxyLogin", description:tr("Proxy Login. Can be blank."), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#input_constructor').html())({id:"ProxyPassword", description:tr("Proxy password. Can be blank."), default_selector: "string", disable_int:true}) %>
      <%= _.template($('#targetfields').html())({}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd",use_target:true, visible:true}) %>
  </script>

  _MACRO_INSERT_INTERFACE_

  <script type="text/template" id="log">
    <div class="container-fluid log">
      <%= _.template($('#input_constructor').html())({id:"LogText", description:tr("Data to Log"), default_selector: "string"}) %>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="clearlog">
    <div class="container-fluid log">
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>

  <script type="text/template" id="solverfailed">
    <div class="container-fluid log">
      <div class="tooltipinternal tr">Use this action if last captcha was solved wrong.</div>
    </div>
    <%= _.template($('#back').html())({action:"executeandadd", visible:true}) %>
  </script>


  <script type="text/template" id="log_code">
      log(<%= text %>)
  </script>

  <script type="text/template" id="clearlog_code">
      clear_log()
  </script>

  <script type="text/template" id="solverfailed_code">
      solver_failed()
  </script>

  
  <script type="text/template" id="emailsettings_code">
      imap_client_set_config(<%= host %>, <%= username %>, <%= password %>, <%= port %>, <%= encryption %>, <%= inbox %>)
  </script>
  <script type="text/template" id="emailproxy_code">
      var hash = proxy_parse(<%= ProxyText %>)
      if(<%= ProxyType %> != "auto" ){
        hash["IsHttp"] = <%= ProxyType %> == "http"
      }
      var login = <%= ProxyLogin %>
      var password = <%= ProxyPassword %>
      if(login.length > 0 && password.length > 0 )
      {
        hash["name"] = login
        hash["password"] = password
      }
      imap_client_set_proxy(hash["server"], hash["Port"], hash["IsHttp"], hash["name"], hash["password"])
  </script>
  <script type="text/template" id="emaillength_code">
      <%= timeout_general() %>
      imap_client_pull_messages_length()!
      <%= variable %> = imap_client_messages_length()
  </script>
  <script type="text/template" id="emailsearchfirst_code">
      <%= timeout_general() %>
      imap_client_search(<%= sender %>,<%= subject %>,<%= body %>)!
      <%= variable %> = imap_client_search_result()
      if(<%= variable %>.length > 0)
        <%= variable %> = <%= variable %>[<%= variable %>.length - 1]
      else
        <%= variable %> = ""
      <%= timeout_general() %>
      imap_client_pull_message(<%= variable %>)!
      <%= variable %> = imap_client_message()

      var csv_parse_result = <%= variable %>.match(LINK_REGEXP) || []
      <% for(var i = 0;i < link_list.length; i++){ %>
        VAR_<%= link_list[i] %> = csv_parse_result[<%= i %>]
        if(typeof(VAR_<%= link_list[i] %>) == 'undefined' || !VAR_<%= link_list[i] %>)
        {
          VAR_<%= link_list[i] %> = ""
        }
      <% } %>
  </script>
  <script type="text/template" id="emailsearchall_code">
      <%= timeout_general() %>
      imap_client_search(<%= sender %>,<%= subject %>,<%= body %>)!
      <%= variable %> = imap_client_search_result().join(",")
  </script>
  <script type="text/template" id="emailpull_code">
      <%= timeout_general() %>
      imap_client_pull_message(<%= value %>)!
      <%= variable %> = imap_client_message()
      var csv_parse_result = <%= variable %>.match(LINK_REGEXP) || []
      <% for(var i = 0;i < link_list.length; i++){ %>
        VAR_<%= link_list[i] %> = csv_parse_result[<%= i %>]
        if(typeof(VAR_<%= link_list[i] %>) == 'undefined' || !VAR_<%= link_list[i] %>)
        {
          VAR_<%= link_list[i] %> = ""
        }
      <% } %>
  </script>
             
  <script type="text/template" id="httpclientproxy_code">
      var hash = proxy_parse(<%= ProxyText %>)
      if(<%= ProxyType %> != "auto" ){
        hash["IsHttp"] = <%= ProxyType %> == "http"
      }
      var login = <%= ProxyLogin %>
      var password = <%= ProxyPassword %>
      if(login.length > 0 && password.length > 0 )
      {
        hash["name"] = login
        hash["password"] = password
      }
      _switch_http_client_main()
      http_client_set_proxy(hash["server"], hash["Port"], hash["IsHttp"], hash["name"], hash["password"])
  </script>
  <script type="text/template" id="httpclientreset_code">
    _switch_http_client_main()
    new_http_client()
  </script>
  <script type="text/template" id="httpclientdownload_code">
    _switch_http_client_main()
    <%= timeout_general() %>
    http_client_download(<%= value %>, <%= file %>)!
  </script>
  <script type="text/template" id="httpclientget_code">
    _switch_http_client_main()
    <% if(follow){ %>
      <%= timeout_general() %>
      http_client_get2(<%= value %>,{method:(<%= method %>)})!
    <% } else {%>
      <%= timeout_general() %>
      http_client_get_no_redirect2(<%= value %>,{method:(<%= method %>)})!
    <% }%>
  </script>
  <script type="text/template" id="httpclientpost_code">
    _switch_http_client_main()
    <% if(follow){ %>
      <%= timeout_general() %>
      http_client_post(<%= value %>, <%= params %>, {"content-type":(<%= contenttype %>), "encoding":(<%= encoding %>), "method":(<%= method %>)})!
    <% } else {%>
      <%= timeout_general() %>
      http_client_post_no_redirect(<%= value %>, <%= params %>, {"content-type":(<%= contenttype %>), "encoding":(<%= encoding %>), "method":(<%= method %>)})!
    <% }%>
  </script>
  <script type="text/template" id="parseline_code">
    var csv_parse_result = csv_parse(<%= value %>)
    <% for(var i = 0;i < list.length; i++){ %>
      VAR_<%= list[i] %> = csv_parse_result[<%= i %>]
      if(typeof(VAR_<%= list[i] %>) == 'undefined' || !VAR_<%= list[i] %>)
      {
        VAR_<%= list[i] %> = ""
      }
    <% } %>
    
  </script>

  
  <script type="text/template" id="httpclienturl_code">
    _switch_http_client_main()
    <%= variable %> = http_client_url()
  </script>
  <script type="text/template" id="httpclientcontent_code">
    _switch_http_client_main()
    <%= variable %> = http_client_content()
  </script>
  <script type="text/template" id="httpclientstatus_code">
    _switch_http_client_main()
    <%= variable %> = http_client_status()
  </script>
  <script type="text/template" id="httpclientgetheader_code">
    _switch_http_client_main()
    <%= variable %> = http_client_header(<%= value %>)
  </script>
  <script type="text/template" id="httpclientsetheader_code">
    _switch_http_client_main()
    http_client_set_header(<%= name %>, <%= value %>)
  </script>
  <script type="text/template" id="httpclientclearheader_code">
    _switch_http_client_main()
    http_client_clear_header()
  </script>
  <script type="text/template" id="httpclientgetcookiesforurl_code">
    _switch_http_client_main()
    <%= variable %> = http_client_get_cookies(<%= value %>)
  </script>
  <script type="text/template" id="httpclientsavecookies_code">
    _switch_http_client_main()  
    <%= variable %> = http_client_save_cookies()
  </script>
  <script type="text/template" id="httpclientrestorecookies_code">
    _switch_http_client_main()
    http_client_restore_cookies(<%= value %>)
  </script>
  <script type="text/template" id="httpclientfailonerror_code">
    _switch_http_client_main()
    http_client_set_fail_on_error(<%= value %> == "fail")
  </script>
  <script type="text/template" id="httpclientiserror_code">
    _switch_http_client_main()
    <%= variable %> = http_client_was_error()
  </script>
  <script type="text/template" id="httpclientgeterrorstring_code">
    _switch_http_client_main()
    <%= variable %> = http_client_error_string()
  </script>
  <script type="text/template" id="httpclientxpathxml_code">
    _switch_http_client_main()
    <%= variable %> = http_client_xpath_xml(<%= value %>,!(<%= fail %>))
  </script>
  <script type="text/template" id="httpclientxpathxmllist_code">
    _switch_http_client_main()
    <%= variable %> = http_client_xpath_xml_list(<%= value %>,true)
  </script>
  <script type="text/template" id="httpclientxpathtext_code">
    _switch_http_client_main()
    <%= variable %> = http_client_xpath_text(<%= value %>,!(<%= fail %>))
  </script>
  <script type="text/template" id="httpclientxpathtextlist_code">
    _switch_http_client_main()
    <%= variable %> = http_client_xpath_text_list(<%= value %>,true)
  </script>
  <script type="text/template" id="httpclientxpathcount_code">
    _switch_http_client_main()
    <%= variable %> = http_client_xpath_count(<%= value %>)
  </script>
  <script type="text/template" id="httpclientxpathexists_code">
    _switch_http_client_main()
    <%= variable %> = http_client_xpath_exist(<%= value %>)
  </script>


  <script type="text/template" id="executefunction_code">
      _call(<%= name %>,null)!
  </script>

  <script type="text/template" id="executefunctioninseveralthreads_code">
      _call_section(<%= name %>,<%= thread %>,<%= success %>,<%= fail %>)!
  </script>

  <script type="text/template" id="xml_code">
      /*Browser*/
      <%= waiter %>
      <%= path %>.xml()!
      <%= variable %> = _result()
  </script>

  <script type="text/template" id="coordinates_code">
      /*Browser*/
      <%= waiter %>
      <%= path %>.script("(function(){var rect = self.getBoundingClientRect();return (rect.left + positionx).toString() + '|' + (rect.top + positiony).toString() + '|' + (rect.right - rect.left).toString() + '|' + (rect.bottom - rect.top).toString()})();")!
      if(_result().length > 0)
      {
        var split = _result().split("|")
        <%= x %> = parseInt(split[0])
        <%= y %> = parseInt(split[1])
        <%= width %> = parseInt(split[2])
        <%= height %> = parseInt(split[3])
      }
  </script>


  <script type="text/template" id="restrictpopups_code">
      /*Browser*/
      _restrict_popups()!
  </script>

  <script type="text/template" id="allowpopups_code">
      /*Browser*/
      _allow_popups()!
  </script>

  <script type="text/template" id="restrictdownloads_code">
      /*Browser*/
      _restrict_downloads()!
  </script>

  <script type="text/template" id="allowdownloads_code">
      /*Browser*/
      _allow_downloads()!
  </script>

  <script type="text/template" id="captcha_code">
      /*Browser*/
      solver_properties_clear(<%= method %>)
      if(<%= method %> == "rucaptcha")
      {
        rucaptcha(<%= antigate %>)
      }
      if(<%= method %> == "antigate")
      {
       antigate(<%= antigate %>)
      }
      if(<%= method %> == "dbc")
      {
        dbc(<%= antigate %>)
      }
      if(<%= method %> == "2captcha")
      {
        twocaptcha(<%= antigate %>)
      }
      if(<%= method %> == "capmonster" || <%= method %> == "capmonsterimage" || <%= method %> == "capmonsteraudio")
      {
        solver_property("capmonster","serverurl",<%= serverurl %>)
        capmonster(<%= antigate %>)
      }


      <%= waiter %>
      <%= path %>.exist()!
      _if(_result() == "1", function(){
        _if_else(<%= method %> == "capmonster" || <%= method %> == "capmonsterimage" || <%= method %> == "capmonsteraudio" || <%= method %> == "captchasniper", function(){
          <%= path %>.attr("src")!
          <%= variable %> = _result()
          _if(<%= variable %>.length == 0, function(){
            <%= path %>.css("img").attr("src")!
            <%= variable %> = _result()
          })!

          if(<%= variable %>.length == 0)
          {
            fail(tr("Image tag not found. Is this element captcha?"))
          }

          wait_load(<%= variable %>)!

          cache_get_base64(<%= variable %>)!

          if(_result().length == 0)
          {
            fail(tr("Url ") + <%= variable %> + tr(" is not present in cache. Please enable cache before page load with Cache Mask Allow action"))
          }

          _if_else(<%= method %> == "captchasniper", function(){
            _switch_http_client_internal()
            http_client_post(<%= serverurl %>, ["file","base64://" + _result()], {"content-type":("multipart"), "encoding":("UTF-8"), "method":("POST")})!
            {var split = http_client_content().split("|");<%= variable %> = split[split.length-1]}
            _switch_http_client_main()
          }, function(){
            <%= timeout_solver() %>
            solve_base64("capmonster", _result())!
            <%= variable %> = _result()
          })!

        },function(){
          <%= path %>.render_base64()!
          <%= timeout_solver() %>
          solve_base64(<%= method %>, _result())!
          <%= variable %> = _result()

        })!
    })!

      
  </script>

  <script type="text/template" id="screenshot_code">
      /*Browser*/
      <%= waiter %>
      <%= path %>.exist()!
      _if(_result() == "1", function(){
          <%= path %>.render_base64()!
          <%= variable %> = _result()
      })!
  </script>

  <script type="text/template" id="replacestring_code">
      <%= variable %> = (<%= value %>).split(<%= from %>).join(<%= to %>)
  </script>

  <script type="text/template" id="template_code">
      _template(<%= template %>)!
      <%= variable %> = _spintax(_result())
  </script>


  <script type="text/template" id="randomstring_code">
      <%= variable %> = Array(<%= length %>).join().split(',').map(function() { return (<%= chars %>).charAt(Math.floor(Math.random() * <%= chars %>.length)); }).join('')
  </script>


  <script type="text/template" id="randomint_code">
      <%= variable %> = Math.floor(Math.random() * (parseInt(<%= max %>) - parseInt(<%= min %>) + 1)) + parseInt(<%= min %>)
  </script>



  

  _MACRO_INSERT_CODE_

  <script type="text/template" id="exist_code">
      /*Browser*/
      <% if(imagesearch){ %>
        <%= waiter %>        
      <% }else if(query){ %>
        ;_SELECTOR=<%=query%>;
      <% } %>

      <%= path %>.exist()!
      <%= variable %> = _result() == 1
      <% if(isvisible){ %>
        _if(<%= variable %>, function(){
          <%= path %>.style("display")!
          STYLE_DISPLAY = _result()

          <%= path %>.style("visibility")!
          STYLE2_DISPLAY = _result()

          <%= path %>.script("self.getBoundingClientRect().height")!
          STYLE_HEIGHT = _result()

          <%= path %>.script("self.getBoundingClientRect().width")!
          STYLE_WIDTH = _result()
          
          <%= variable %> = STYLE_DISPLAY != "none" && STYLE2_DISPLAY != "hidden" && STYLE_HEIGHT != "0"  && STYLE_WIDTH != "0"
          
        })!
      <% } %>

  </script>

  <script type="text/template" id="restorecookies_code">
      /*Browser*/

      VALUE = <%= value %>
      COOKIES = ""
      if(VALUE.length > 0)
      {
        COOKIES = JSON.parse(VALUE)["cookies"]
        if(typeof(COOKIES) == "undefined")
          COOKIES = ""
        else
          COOKIES = JSON.stringify(COOKIES)
      }


      restore_cookies(COOKIES)!
  </script>

  <script type="text/template" id="loadcookiesfromhttpclient_code">
      /*Browser*/
      _switch_http_client_main()
      VALUE = http_client_save_cookies()
      COOKIES = ""
      if(VALUE.length > 0)
      {
        COOKIES = JSON.parse(VALUE)["cookies"]
        if(typeof(COOKIES) == "undefined")
          COOKIES = ""
        else
          COOKIES = JSON.stringify(COOKIES)
      }

      
      restore_cookies(COOKIES)!
  </script>

  <script type="text/template" id="loadcookiesfrombrowser_code">
      /*Browser*/
      save_cookies()!
      _switch_http_client_main()
      http_client_restore_cookies(JSON.stringify({cookies:JSON.parse(_result())}))
  </script>

  <script type="text/template" id="closebrowser_code">
      /*Browser*/
      /*ManualBrowser*/
      close_browser()
  </script>

  <script type="text/template" id="openbrowser_code">
      /*Browser*/
      /*ManualBrowser*/
      open_browser()!
  </script>

  <script type="text/template" id="setheader_code">
    /*Browser*/
    header(<%= name %>, <%= value %>)!
  </script>

  <script type="text/template" id="solvecaptcha_code">
      /*Browser*/
      solver_properties_clear(<%= method %>)
      if(<%= method %> == "rucaptcha")
      {
        rucaptcha(<%= antigate %>)
      }
      if(<%= method %> == "antigate")
      {
        antigate(<%= antigate %>)
      }
      if(<%= method %> == "dbc")
      {
        dbc(<%= antigate %>)
      }
      if(<%= method %> == "2captcha")
      {
        twocaptcha(<%= antigate %>)
      }
      if(<%= method %> == "capmonster" || <%= method %> == "capmonsterimage" || <%= method %> == "capmonsteraudio")
      {
        solver_property("capmonster","serverurl",<%= serverurl %>)
        capmonster(<%= antigate %>)
      }

      _if_else(<%= method %> == "captchasniper", function(){
        _switch_http_client_internal()
        http_client_post(<%= serverurl %>, ["file","base64://" + <%= value %>], {"content-type":("multipart"), "encoding":("UTF-8"), "method":("POST")})!
        {var split = http_client_content().split("|");<%= variable %> = split[split.length-1]}
        _switch_http_client_main()
      }, function(){
        <%= timeout_solver() %>
        solve_base64(<%= method %>,<%= value %>)!
        <%= variable %> = _result()
      })!


      
  
  </script>

  <script type="text/template" id="timeout_code">
      <% if(type == "general"){ %>
        general_timeout(<%= timeout %>)
      <% }else if(type == "fullpageload"){ %>
        async_load_timeout(<%= timeout %>)
      <% }else{ %>
        solver_timeout(<%= timeout %>)
      <% } %>
  </script>

  <script type="text/template" id="savecookies_code">
      /*Browser*/
      save_cookies()!
      COOKIES = JSON.parse(_result())
      <%= variable %> = JSON.stringify({cookies:COOKIES})
  </script>

  <script type="text/template" id="style_code">
      /*Browser*/
      <%= waiter %>
      <%= path %>.style(<%= style %>)!
      <%= variable %> = _result()
  </script>

  <script type="text/template" id="typeelement_code">
      /*Browser*/
      <%= waiter %>
      <% if(!disableemulation){ %>
        <%= path %>.random_point()!
        _if(_result().length > 0, function(){
          move(<%= move_settings %>)!
          <%= path %>.clarify(X,Y)!
          _call(_clarify,<%= move_settings %>)!
          mouse(X,Y)!
          <%= timeout_general() %>
          page().type(<%= text %>,<%= interval %>)!
        })!
      <% }else{ %>
        <%= path %>.script("self.value=(" + JSON.stringify(<%= text %>) + ")")!
      <% } %>
  </script>

  <script type="text/template" id="clear_code">
      /*Browser*/
      <%= waiter %>
      <%= path %>.random_point()!
      _if(_result().length > 0, function(){
        move(<%= move_settings %>)!
        <%= path %>.clarify(X,Y)!
        _call(_clarify,<%= move_settings %>)!
        mouse(X,Y)!
        page().type("<CONTROL>a<DELETE>")!
      })!
  </script>

  <script type="text/template" id="clickelement_code">
      /*Browser*/
      <%= waiter %>
      <% if(!disableemulation){ %>
        <%= path %>.random_point()!
        _if(_result().length > 0, function(){        
          X = parseInt(_result().split(",")[0])
          Y = parseInt(_result().split(",")[1])
          mouse(X,Y)!
        })!
      <% }else{ %>
        <%= path %>.script("self.click()")!
      <% } %>
  </script>

  <script type="text/template" id="check_code">
      /*Browser*/
      <%= waiter %>
      <%= path %>.random_point()!
      _if(_result().length > 0, function(){
        move(<%= move_settings %>)!
        <%= path %>.clarify(X,Y)!
        _call(_clarify,<%= move_settings %>)!
        mouse(X,Y)!
      })!
  </script>

  <script type="text/template" id="focus_code">
      /*Browser*/
      <%= waiter %>
      <%= path %>.focus()!
  </script>

  <script type="text/template" id="reset_code">
      /*Browser*/
      <% if(reset){ %>
        new_browser()!
      <% }else{ %>
        reset()!
      <% } %>
  </script>

  <script type="text/template" id="moveelement_code">
      /*Browser*/
      <%= waiter %>
      <%= path %>.random_point()!
      _if(_result().length > 0, function(){
        move(<%= move_settings %>)!
        <%= path %>.clarify(X,Y)!
        _call(_clarify,<%= move_settings %>)!
      })!
  </script>

  <script type="text/template" id="moveandclickelement_code">
      /*Browser*/
      <%= waiter %>
      <% if(!disableemulation){ %>
        <%= path %>.random_point()!
        _if(_result().length > 0, function(){
          move(<%= move_settings %>)!
          <%= path %>.clarify(X,Y)!
          _call(_clarify,<%= move_settings %>)!           
          mouse(X,Y)!
        })!
      <% }else{ %>
        <%= path %>.script("self.click()")!
      <% } %>
  </script>

  <script type="text/template" id="dragelement_code">
      /*Browser*/
      <%= waiter %>
      <%= path %>.random_point()!
      _if(_result().length > 0, function(){
        move(<%= move_settings %>)!
        <%= path %>.clarify(X,Y)!
        _call(_clarify,<%= move_settings %>)!           
        mouse_down(X,Y)!
      })!
  </script>

  <script type="text/template" id="dropelement_code">
      /*Browser*/
      <%= waiter %>
      <%= path %>.random_point()!
      _if(_result().length > 0, function(){
        move(<%= move_settings %>)!
        <%= path %>.clarify(X,Y)!
        _call(_clarify,<%= move_settings %>)!           
        mouse_up(X,Y)!
      })!
  </script>

  <script type="text/template" id="text_code">
      /*Browser*/
      <%= waiter %>
      <%= path %>.text()!
      <%= variable %> = _result()
  </script>

  <script type="text/template" id="length_code">
      /*Browser*/
      <% if(query){ %>
        ;_SELECTOR=<%=query%>;
      <% } %>
      <%= path %>.length()!
      <%= variable %> = _result()
  </script>

  <script type="text/template" id="script_code">
      /*Browser*/
      <%= waiter %>
      <%= path %>.script(<%= script %>)!
      <%= variable %> = _result()
  </script>

  <script type="text/template" id="javascript_code">
      /*Browser*/
      page().script(<%= value %>)!
      <%= variable %> = _result()
  </script>

  <script type="text/template" id="onloadjavascript_code">
      /*Browser*/
      onloadjavascript(<%= value %>)!
  </script>

  
  <script type="text/template" id="set_code">
      /*Browser*/
      <%= waiter %>
      <%= path %>.move()!
      <%= timeout_general() %>
      <%= path %>.set(<%= set %>)!
  </script>

  <script type="text/template" id="waitelement_code">
      /*Browser*/
      <%= waiter %>
  </script>

  <script type="text/template" id="waitfullload_code">
      /*Browser*/
      <%= timeout_waiter() %>
      wait_async_load()!
  </script>

  <script type="text/template" id="set_integer_code">
      /*Browser*/
      <%= waiter %>
      <%= path %>.move()!
      <%= timeout_general() %>
      <%= path %>.set_integer(<%= set %>)!
  </script>

  <script type="text/template" id="set_random_code">
      /*Browser*/
      <%= waiter %>
      <%= path %>.move()!
      <%= timeout_general() %>
      <%= path %>.set_random()!
  </script>

  <script type="text/template" id="attr_code">
      /*Browser*/
      <%= waiter %>
      <%= path %>.attr(<%= attr %>)!
      <%= variable %> = _result()
  </script>

  <script type="text/template" id="set_attr_code">
      /*Browser*/
      <%= waiter %>
      <%= path %>.set_attr(<%= name %>, <%= value %>)!
  </script>

  <script type="text/template" id="url_code">
      /*Browser*/
      url()!
      <%= variable %> = _result()
  </script>

  <script type="text/template" id="setvariable_code">
      <%= variable_name %> = <%= variable_value %>
  </script>

  <script type="text/template" id="incvariable_code">
      <%= variable_name %> = parseInt(<%= variable_name %>) + parseInt(<%= variable_value %>)
  </script>

  <script type="text/template" id="incglobalvariable_code">
      PSet("basglobal", <%= variable_name %>, parseInt(JSON.parse(P("basglobal", <%= variable_name %>) || "0")) + parseInt(<%= variable_value %>))
  </script>

  <script type="text/template" id="resource_code">
      RS("<%= je(resource) %>", <%= notreuse %>, <%= onlyfail %>)!
      <%= variable %> = _result().get()
  </script>

  <script type="text/template" id="click_code">
      /*Browser*/
      mouse(<%= x %>,<%= y %>)!
  </script>

  <script type="text/template" id="move_code">
      /*Browser*/
      move(<%= x %>,<%= y %>, <%= move_settings %>)!
  </script>

  <script type="text/template" id="addtab_code">
      /*Browser*/
      page().script("window.open(" + JSON.stringify(<%= url %>) + ")")!
  </script>

  <script type="text/template" id="closetab_code">
      /*Browser*/
      popupclose(<%= index %>)!
  </script>

  <script type="text/template" id="selecttab_code">
      /*Browser*/
      popupselect(<%= index %>)!
  </script>

  <script type="text/template" id="moveandclick_code">
      /*Browser*/
      move(<%= x %>,<%= y %>, <%= move_settings %>)!
      mouse(<%= x %>,<%= y %>)!
  </script>

  <script type="text/template" id="drag_code">
      /*Browser*/
      move(<%= x %>,<%= y %>, <%= move_settings %>)!
      mouse_down(<%= x %>,<%= y %>)!
  </script>

  <script type="text/template" id="drop_code">
      /*Browser*/
      move(<%= x %>,<%= y %>, <%= move_settings %>)!
      mouse_up(<%= x %>,<%= y %>)!
  </script>

  <script type="text/template" id="load_code">
      /*Browser*/
      <% if(notinstant){ %>
        <%= timeout_general()  %>
        load(<%= url %>)!
      <% }else{ %>
        load_instant(<%= url %>)!
      <% } %>
  </script>

  <script type="text/template" id="mousesettings_code">
      /*Browser*/
      _default_move_params({speed: <%= speed %>,gravity: <%= gravity %>,deviation: <%= deviation %>})
  </script>

  <script type="text/template" id="browsersettings_code">

      var Params = {};
      var IsSafe = (<%= IsSafe %>);
      var UseFlash = (<%= UseFlash %>);
      var SkipFrames = (<%= SkipFrames %>);
      var RefreshConnections = (<%= RefreshConnections %>);
      var EncodeUtf8 = (<%= EncodeUtf8 %>);

      if(IsSafe.length > 0)
        Params["IsSafe"] = IsSafe == "true"
      if(UseFlash.length > 0)
        Params["UseFlash"] = UseFlash == "true"
      if(SkipFrames !== 0)
        Params["SkipFrames"] = SkipFrames
      if(RefreshConnections.length > 0)
        Params["RefreshConnections"] = RefreshConnections == "true"
      if(EncodeUtf8.length > 0)
        Params["EncodeUtf8"] = EncodeUtf8 == "true"

      _settings(Params)!
      
  </script>

  <script type="text/template" id="resize_code">
      /*Browser*/
      resize(<%= width %>, <%= height %>)!
  </script>

  <script type="text/template" id="sleep_fromto_code">
      sleep(rand(<%= from %>,<%= to %>))!
  </script>

  <script type="text/template" id="sleep_code">
      sleep(<%= t %>)!
  </script>


  <script type="text/template" id="result_code">
    result(<%= value %>, <%= number %>)
  </script>
  
  
  <script type="text/template" id="base64_code">
    <% if(encode) { %>
      <%= variable %> = base64_encode(<%= value %>)
    <% }else{ %>
      <%= variable %> = base64_decode(<%= value %>)
    <% } %>  </script>

  <script type="text/template" id="globalset_code">
    var val = JSON.stringify(<%= value %>);
    PSet("basglobal", <%= key %>, val)
  </script>

  <script type="text/template" id="globalget_code">
    var text = P("basglobal", <%= key %>)
    if(text.length == 0)
      text="\"\""
    <%= variable %> = JSON.parse(text)
  </script>


  <script type="text/template" id="cachemaskallow_code">
    /*Browser*/
    cache_allow(<%= value %>)!
  </script>

  <script type="text/template" id="cachemaskdeny_code">
    /*Browser*/
    cache_deny(<%= value %>)!
  </script>

  <script type="text/template" id="requestmaskallow_code">
    /*Browser*/
    request_allow(<%= value %>)!
  </script>

  <script type="text/template" id="requestmaskdeny_code">
    request_deny(<%= value %>)!
  </script>

  <script type="text/template" id="cleardata_code">
    /*Browser*/
    cache_data_clear()!
  </script>

  <script type="text/template" id="clearmasks_code">
    /*Browser*/
    cache_masks_clear()!
  </script>

  <script type="text/template" id="getstatus_code">
    /*Browser*/
    cache_get_status(<%= value %>)!
    <%= variable %> = _result()
  </script>

  <script type="text/template" id="isloaded_code">
    /*Browser*/
    is_load(<%= value %>)!
    <%= variable %> = _result()
  </script>

  <script type="text/template" id="getfromcache_code">
    /*Browser*/
    <%= timeout_waiter() %>
    wait_load(<%= value %>)!
    <% if(base64){ %>
      cache_get_base64(<%= value %>)!
      <%= variable %> = _result()
    <% }else{ %>
      cache_get_string(<%= value %>)!
      <%= variable %> = _result()
    <% } %>
  </script>

  <script type="text/template" id="renderscreen_code">
      /*Browser*/
      render(<%= x %>,<%= y %>,<%= width %>,<%= height %>)!
      <%= variable %> = _result()
  </script>

  <script type="text/template" id="scroll_code">
      /*Browser*/
      scroll(<%= x %>,<%= y %>)!
  </script>

  <script type="text/template" id="waitload_code">
      /*Browser*/
      <%= timeout_waiter() %>
      wait_load(<%= waiter %>)!
  </script>

  <script type="text/template" id="waiturl_code">
      /*Browser*/
      <%= timeout_waiter() %>
      wait_url(<%= waiter %>)!
  </script>

  <script type="text/template" id="openfile_code">
      /*Browser*/
      open_file_dialog(<%= value %>)!
  </script>

  <script type="text/template" id="promptresult_code">
      /*Browser*/
      prompt_result(<%= value %>)!
  </script>

  <script type="text/template" id="httpauth_code">
      /*Browser*/
      http_auth_result(<%= login %>,<%= password %>)!
  </script>

  <script type="text/template" id="waitcontent_code">
      /*Browser*/
      <%= timeout_waiter() %>
      wait_content(<%= waiter %>)!
  </script>

  <script type="text/template" id="waitfiledownload_code">
      /*Browser*/
      <%= timeout_waiter() %>
      wait_load("download://*")!
      cache_get_string("download://*")!
      <%= variable %> = _result()
  </script>
  

  <script type="text/template" id="waitcss_code">
      /*Browser*/
      <%= timeout_waiter() %>
      wait_css(<%= waiter %>)!
  </script>

  <script type="text/template" id="type_code">
      /*Browser*/
      <%= timeout_general() %>
      page().type(<%= text %>,<%= interval %>)!
  </script>

  <script type="text/template" id="html_code">
      /*Browser*/
      page().script("document.documentElement.outerHTML")!
      <%= variable %> = _result()
  </script>

  <script type="text/template" id="if_code">
      _if(<%= expression %>,function(){
        section_insert()
      })!
      <% if(do_delete.length > 0){ %>
        delete <%= do_delete %>;
      <% } %>
  </script>

  <script type="text/template" id="proxy_code">
      /*Browser*/
      var hash = proxy_parse(<%= ProxyText %>)
      if(<%= ProxyType %> != "auto" ){
        hash["IsHttp"] = <%= ProxyType %> == "http"
      }
      var login = <%= ProxyLogin %>
      var password = <%= ProxyPassword %>
      if(login.length > 0 && password.length > 0 )
      {
        hash["name"] = login
        hash["password"] = password
      }
      set_proxy(hash["server"], hash["Port"], hash["IsHttp"], hash["name"], hash["password"])!
  </script>

  <script type="text/template" id="for_code">
      _do(function(){
        VAR_CYCLE_INDEX = _iterator() - 1 + parseInt(<%= expression_from %>)
        if(VAR_CYCLE_INDEX > parseInt(<%= expression_to %>))_break();
        section_insert()
      })!
  </script>

  <script type="text/template" id="ignoreerrors_code">
    _call(function()
    {
      _on_fail(function(){
       VAR_LAST_ERROR = _result()
       VAR_WAS_ERROR = true
       _break()
       })
       VAR_WAS_ERROR = false
       CYCLES.Current().RemoveLabel("function")
       section_insert()
    },null)!

  </script>

  <script type="text/template" id="foreach_code">
      <% var r = Math.floor(Math.random() * (999999 - 100000) + 100000) %>
      FOREACH_ARRAY_<%= r %> = <%= for_array %>
      _do(function(){
        VAR_CYCLE_INDEX = _iterator() - 1
        if(VAR_CYCLE_INDEX > FOREACH_ARRAY_<%= r %>.length - 1)_break();
        VAR_FOREACH_DATA = FOREACH_ARRAY_<%= r %>[VAR_CYCLE_INDEX]
        section_insert()
      })!
      delete FOREACH_ARRAY_<%= r %>
  </script>

  <script type="text/template" id="loopelement_code">
      /*Browser*/
      <%= waiter %>
      <%= path %>.length()!
      ELEMENT_LENGTH = _result()
      VAR_FOR_EACH_CSS = <%= querycss %>
      VAR_FOR_EACH_MATCH = <%= querymatch %>
      <% if(queryxpath){ %>
        VAR_FOR_EACH_XPATH = <%= queryxpath %>
      <% } %>


      _do(function(){
        VAR_CYCLE_INDEX = _iterator() - 1
        if(VAR_CYCLE_INDEX >= ELEMENT_LENGTH)_break();
        section_insert()
      })!
  </script>

  <script type="text/template" id="while_code">
      _do(function(){
        VAR_CYCLE_INDEX = _iterator() - 1
        <%= additional %>
        BREAK_CONDITION = <%= expression %>;
        if(!BREAK_CONDITION)_break();
        section_insert()
      })!
  </script>

  
  <script type="text/template" id="getcookiesforurl_code">
      /*Browser*/
      get_cookies(<%= value %>)!
      <%= variable %> = _result()
  </script>

  <script type="text/template" id="break_code">
      _break("function")
  </script>

  <script type="text/template" id="continue_code">
      _next("function")
  </script>

  <script type="text/template" id="success_code">
      success(<%= message %>)
  </script>

  <script type="text/template" id="fail_code">

      fail(<%= message %>,<%= dontrestart %>)
  </script>

  <script type="text/template" id="die_code">
      die(<%= message %>,<%= instant %>)
  </script>

  <script type="text/template" id="label_code">
      _set_goto_label(<%= label %>)!
  </script>

  <script type="text/template" id="goto_code">
      _goto(<%= label %>)!
  </script>

  <script type="text/template" id="custom_code">
      <%= code %>
  </script>

  <!-- ========= -->
  <!-- Libraries -->
  <!-- ========= -->
  <script src="jquery-2.1.3.min.js" type="text/javascript"></script>
  <script src="jquery.mousewheel.js" type="text/javascript"></script>
  <script src="lodash.js" type="text/javascript"></script>
  <script src="backbone.js" type="text/javascript"></script>
  <script src="bootstrap.min.js"></script>
  <script src="bootbox.min.js"></script>
  <script src="../actions/actions.js"></script>
  <script src="translate.js"></script>
  <script src="expressioneditor.js"></script>
  <script src="rappid.js"></script>
  <script src="tooledViewPlugin.js"></script>
  <script src="preservemainpage.js"></script>
  <script src="databasefilter.js"></script>
  <script src="sortable.js"></script>
  <script src="search.js"></script>
  <script src="typeahead.js"></script>
  <script src="cursorposition.js"></script>
  
  <script type="text/javascript"> _L = $.extend(_L, _AL)</script>
  <script type="text/javascript"> _MACRO_INSERT_LOCALIZE_ </script>
  <script type="text/javascript"> _MACRO_INSERT_ACTIONS_ </script>

  <!-- ========= -->
  <!--   Styles  -->
  <!-- ========= -->
  <link rel="stylesheet" href="bootstrap.min.css">
  <link rel="stylesheet" href="style.css">
  <link rel="stylesheet" href="font-awesome.min.css">
  <link rel="stylesheet" href="expressioneditor.css">
  <link rel="stylesheet" href="rappid.css">
  <link rel="stylesheet" href="typeahead.css">
  <link rel="stylesheet" href="bootstrap-checkbox.css">



  <!-- =============== -->
  <!-- Javascript code -->
  <!-- =============== -->
  <script type="text/javascript">
    var _Filter = new Filter();

    var TaskModel = Backbone.Model.extend({
        defaults: {
            name: "",
            description: "",
            ref: ""
        }
    });
    var ResourceModel = Backbone.Model.extend({
        defaults: {
            name: "",
            description: ""
        }
    });
    var VariableModel = Backbone.Model.extend({
        defaults: {
            name: ""
        }
    });
    var FunctionModel = Backbone.Model.extend({
        defaults: {
            name: ""
        }
    });
    var LabelModel = Backbone.Model.extend({
        defaults: {
            name: ""
        }
    });
    var GobalModel = Backbone.Model.extend({
        defaults: {
            state: "main",
            isedit: false,
            x: "",
            y: "",
            index: 0
        },
        GetPageInfo: function()
        {
          var state = this.get("state")
          var task = _TaskCollection.find(function(item){
            return item.get("ref") == state
          });
          if(task)
            return task.get("name")

          return null;
          
        }
    });
    var SelectorModel = Backbone.Model.extend({
        defaults: {
            css: "",
            css1: "",
            css2: "",
            css3: "",
            match: "",
            xpath: "",
            mousex: 0,
            mousey: 0,
            current: "css",
            is_editing: false,
            is_image:false,
            image_data:"",
            version: "1.0"
        }
    });

    function BrowserAutomationStudio_HasPathChoice()
    {
      var m = _SelectorModel.toJSON()
      return m["current"] == "css" && m["is_editing"] == false && (("css1" in m && m["css1"].length > 0) + ("css2" in m && m["css2"].length > 0) + ("css3" in m && m["css3"].length > 0) > 1)
    }

    

    var TaskCollection = Backbone.Collection.extend({
        model: TaskModel
    });
    var ResourceCollection = Backbone.Collection.extend({
        model: ResourceModel
    });
    var VariableCollection = Backbone.Collection.extend({
        model: VariableModel
    });
    var GlobalVariableCollection = Backbone.Collection.extend({
        model: VariableModel
    });
    var FunctionCollection = Backbone.Collection.extend({
        model: FunctionModel
    });
    var LabelCollection = Backbone.Collection.extend({
        model: LabelModel
    });

    var MainView = Backbone.View.extend({
      el: '#container',

      currentInputResource: "none",
      currentInputVariable: "none",
      currentInputLabel: "none",

      events: {
        "click #ok": "accept",
        "click #WaitingDisable": "interrupt",
        //"mouseover .toolbutton": "showtooltip",
        "click #backtomain": "backtomain",
        "show.bs.modal #VariableModal": "varaddstart",
        "mousedown .var": "varaddstarttrigger",

        "click .varok": "varadd",
        "show.bs.modal #FunctionModal": "funcaddstart",
        "show.bs.modal #LabelModal": "labeladdstart",

        "click .funcok": "funcadd",
        "click .labelok": "labeladd",

        "click .timeoutok": "timeoutadd",
        "click .timeoutdefault": "timeoutdefault",
        "click .groupshow": "groupshow",
        "click .returntomain": "returntomain",
        "click #showhistory": "showhistory",
        "click #showbookmarks": "showbookmarks",
        "mouseup #showhistory": "showhistorymouseup",
        "mouseup #showbookmarks": "showbookmarksmouseup",
        

        "show.bs.modal #RecourseModal": "resaddstart",
        "mousedown .res": "resaddstarttrigger",
        "click .resok": "resadd",
        "click .rescontinue": "rescontinue",
        "mousedown .edit": "editstart",
        "click .specialletter": "specialletter",
        "click #executetype button":"clickexecutetype",
        "click #css":"css",
        "click #match":"match",
        "click #xpath":"xpath",
        "click #at":"at",
        "click #none":"none",
        "click .string": "string",
        "click .expression": "expression",
        "click .int": "int",
        "change .groupselector": "groupselector",
        "mousedown .variant": "selectvariant",
        "click .addtopost": "addpostdata",
        "click .addtopostfile": "addpostdatafile",
        "click .addtopostbase64": "addpostdatabase64",

        "click #use-waiter": "usewaiterchange",
        "click #use-timeout": "usetimeoutchange",
        "click #use-target": "usetargetchange",
        "click #use-move": "usemovechange",

        "click #searchinputclear": "searchinputclear",
        "input #searchinput": "searchinput",
        "keyup #searchinput": "searchinputkeyup",
        "focus .dropdown-menu-path": "dropdownmenupathfocus",
        "blur .dropdown-menu-path": "dropdownmenupathblur",
        "click .dropdown-menu-path": "stoppropagation",
        "keyup .dropdown-menu-path": "pathchanged",
        "mousedown .dropdown-menu-css-item": "dropdownmenupathselectitem",

        "change #Table": "tablechange",
        "mouseenter .tool": "toolmouseenter",
        "mouseleave .tool": "toolmouseleave",

        "focus .input_selector_string": "input_selector_focus",
        "blur .input_selector_string": "input_selector_blur",
        "focus .input_selector_number": "input_selector_focus",
        "blur .input_selector_number": "input_selector_blur",
        "focus .variable-input": "input_selector_focus",
        "blur .variable-input": "input_selector_blur",
        "focus .resource-input": "input_selector_focus",
        "blur .resource-input": "input_selector_blur",
        "change #checkbox-image-show-data": "toggleimageshowdata",
        "change #ImageBase64": "imagebase64changed",
        "click #ImageDataRef": "showimage",
        
     },
      showimage: function(event)
      {
        event.preventDefault();
        event.stopPropagation();
        var dialog = bootbox.alert({
          message: $("<img/>").attr("src",$("#ImageData").attr("src")).attr("class","img-responsive")[0].outerHTML
   
        });
      },

      imagebase64changed:function()
      {
        var data = $("#ImageBase64").val()
        $("#ImageData").attr("src","data:image/png;base64," + data)
      },

      toggleimageshowdata:function()
      {
        if($("#checkbox-image-show-data").prop("checked"))
        {
          $("#ImageBase64Container").show()
        }else
        {
          $("#ImageBase64Container").hide()
        }
      },

      pathchanged:function()
      {
        BrowserAutomationStudio_TestPathInternal();
      },


      input_selector_focus:function(event)
      {
        $(event.target).siblings(".input-field-dropdown").show();
      },

      input_selector_blur:function(event)
      {
        $(event.target).siblings(".input-field-dropdown").hide();  
      },


      toolmouseenter:function(event)
      {
        $(event.target).closest(".tool").addClass("toolhover")
      },

      toolmouseleave:function(event)
      {
        $(event.target).closest(".tool").removeClass("toolhover")
      },

      showhistory:function(event)
      {
        event.preventDefault();
        event.stopPropagation();
        BrowserAutomationStudio_ShowHideHistory();
      },

      showbookmarks:function(event)
      {
        event.preventDefault();
        event.stopPropagation();
        BrowserAutomationStudio_ShowHideBookmarks();
      },
      showhistorymouseup:function(event)
      {
        $("#showhistory").blur();
      },

      showbookmarksmouseup:function(event)
      {
        $("#showbookmarks").blur();
      },

      returntomain:function(event)
      {
        event.preventDefault();
        event.stopPropagation();
        BrowserAutomationStudio_ReturnToMainFunction();
      },

      groupshow:function(event)
      {
        event.preventDefault();
        event.stopPropagation();
        if(CurrentGroup == "")
        {
          var group = $(event.target).closest("a").attr("data-group")
          BrowserAutomationStudio_GotoGroup(group);
        }else
        {
          BrowserAutomationStudio_ReturnToMainFunction();
        }

      },

      tablechange:function(event)
      {
        $("*[data-table-id]").hide()
        $("*[data-table-id=" + $("#Table").val() + "]").show()
        _Filter.Clear()
      },

     
      interrupt: function(event)
      {
        event.preventDefault();
        $("#InterruptMessage").show();
        $("#WaitingDisable").hide();
        BrowserAutomationStudio_Interrupt()
      },

      stoppropagation: function(event)
      {
          event.stopPropagation();
      },

      dropdownmenupathselectitem: function(event)
      {
          event.preventDefault();
          event.stopPropagation();

          $(".dropdown-menu-path").val($(event.target).closest("a").text())
          $(".dropdown-menu-path").blur();
          $(".dropdown-menu-css-options").hide()
          BrowserAutomationStudio_TestPathInternal()
      },

      dropdownmenupathblur: function(event)
      {
          setTimeout(function(){
            $(".dropdown-menu-css-options").hide()  
          }, 100)
      },

      dropdownmenupathfocus: function(event)
      {
        var current = _SelectorModel.get("current")
        if(current == "css")
        {
          $(".dropdown-menu-css-options").show()
        }
      },

      searchinputkeyup: function(event)
      {
        if (event.keyCode === 27)
        {
          $("#searchinput").val("")
          this.searchinput()
        }
      },

      searchinput: function(event)
      {
        var tools = $(".toolbutton")
        var searchterm = $("#searchinput").val().toLowerCase()

      },

      searchinputclear: function(event)
      {
        event.preventDefault();
        $("#searchinput").val("")
        this.searchinput()
      },

      usewaiterchange: function(event)
      {
        event.preventDefault();
        var el = $(event.target).closest("a")
        var new_state = el.attr("data-enabled") != "true"
        el.attr("data-enabled",((new_state) ? "true" : "false") );
        el.removeClass().addClass(((new_state) ? "use-waiter-enabled" : "use-waiter-disabled") );
      },

      usetimeoutchange: function(event)
      {
        event.preventDefault();
        var el = $(event.target).closest("a");
        $('#TimeoutModal').modal() 
        $("#TimeoutValue").val(el.attr("data-value"))
      },

      usetargetchange: function(event)
      {
        event.preventDefault();
        var el = $(event.target).closest("a")
        var new_state = el.attr("data-enabled") != "true"
        el.attr("data-enabled",((new_state) ? "true" : "false") );
        el.removeClass().addClass(((new_state) ? "use-target-enabled" : "use-target-disabled") );
        if(new_state)
        {
          $("#target-data").show()
        }else
        {
          $("#target-data").hide()
        }
      },

      usemovechange: function(event)
      {
        event.preventDefault();
        var el = $(event.target).closest("a")
        var new_state = el.attr("data-enabled") != "true"
        el.attr("data-enabled",((new_state) ? "true" : "false") );
        el.removeClass().addClass(((new_state) ? "use-move-enabled" : "use-move-disabled") );
        if(new_state)
        {
          $("#move-data").show()
        }else
        {
          $("#move-data").hide()
        }
      },

      editstart: function(event)
      {
        event.preventDefault();

        $("#containerdata").hide()
        var target = $(event.target).closest("a")
        var selector = target.attr("data-result-target")
        ToolboxMaximizeCallback = function()
        {
          $("#expressioneditor-container").show()
          document.documentElement.style.zoom = '100%';

          //Get original value
          var value = null
          var data = null
          {
            var Loader = new ResourceLoader()
            Loader.SetIsPrerender(true)
            var id = target.closest("*[data-preserve-id]").attr("data-preserve-id")
            //console.log(id)
            var V = GetInputConstructorValue(id,Loader)
            data = target.closest("*[data-preserve-id]").attr("data-preserve-json")
            if(typeof(data) == "undefined")
              data = ""

            value = V["updated"]
          }
          _ExpressionEditor = new ExpressionEditor(function(Result){
            $("#containerdata").show()
            BrowserAutomationStudio_Minimize()
            $("#expressioneditor-container").hide()
            document.documentElement.style.zoom = _Z + '%'
            if(Result["ok"])
            {
              target.closest("*[data-preserve-id]").attr("data-preserve-json",Result["data"])
              $(selector).val(Result["res"])
              $(selector).closest(".input-group").find(".selector").html("expression")
              $(selector).closest(".input-group").find(".input_selector_number").hide()
              $(selector).closest(".input-group").find(".input_selector_string").show()
            }
          },value,data)
        };
        BrowserAutomationStudio_Maximize();
      },

      backtomain: function()
      {
        BrowserAutomationStudio_EditCancel();
      },
      
      addpostdata: function(event)
      {
        var loader = new ResourceLoader();
        loader.SetIsPrerender(true)
        var Name = GetInputConstructorValue("PostName",loader)["updated"]
        var Value = GetInputConstructorValue("PostValue",loader)["updated"]

        var Data = $("#PostDataArray").val()
        if(Name.length > 0 && Value.length > 0)
        {
          if(Data.length === 0)
          {
            $("#PostDataArray").val(Name  + "," + Value);
          }else
          {
            $("#PostDataArray").val(Data + "," + Name  + "," + Value)
          }
          $("#PostName").val("")
          $("#PostValue").val("")
        }
        
      },

      addpostdatafile: function(event)
      {
        $("#PostValue").val("file://" + $("#PostValue").val());
        this.addpostdata(null)
      },

      addpostdatabase64: function(event)
      {
        $("#PostValue").val("base64://" + $("#PostValue").val());
        this.addpostdata(null)
      },

      selectvariant: function(event)
      {
          var target = $(event.target).closest("a")
          var variant = target.attr("data-variant")
          var result = $("#" + target.attr("data-result"))
          if(result.closest(".input-group").find(".string").length > 0)
          {
            result.closest(".input-group").find(".selector").html("string")
            result.closest(".input-group").find(".input_selector_number").hide()
            result.closest(".input-group").find(".input_selector_string").show()
            result.closest(".input-group").find(".input_selector_string").val(variant)
          }else
          {
            result.closest(".input-group").find(".selector").html("int")
            result.closest(".input-group").find(".input_selector_number").show()
            result.closest(".input-group").find(".input_selector_string").hide()
            result.closest(".input-group").find(".input_selector_number").val(variant)
          }
      },

      groupselector: function(event)
      {
          var target = $(event.target)
          if(target.is(':checked'))
          {
            $("#" + target.attr("data-unchecked-group-id")).hide()
            $("#" + target.attr("data-checked-group-id")).show()
          }
          else
          {
            $("#" + target.attr("data-unchecked-group-id")).show()
            $("#" + target.attr("data-checked-group-id")).hide()
          }
      },

      string: function(event)
      {
        $(event.target).closest(".input-group").find(".selector").html("string")
        $(event.target).closest(".input-group").find(".input_selector_number").hide()
        $(event.target).closest(".input-group").find(".input_selector_string").show()
      },

      int: function(event)
      {
        $(event.target).closest(".input-group").find(".selector").html("int")
        $(event.target).closest(".input-group").find(".input_selector_number").show()
        $(event.target).closest(".input-group").find(".input_selector_string").hide()
      },

      expression: function(event)
      {
        $(event.target).closest(".input-group").find(".selector").html("expression")
        $(event.target).closest(".input-group").find(".input_selector_number").hide()
        $(event.target).closest(".input-group").find(".input_selector_string").show()
      },

      updatepath: function()
      {
        if(_SelectorModel.get("is_image"))
        {
          $(".disable-if-find-by-image").hide()
        }else
        {
          var current = _SelectorModel.get("current")
          
          if(current == "css")
            this.css()
          else if(current == "match")
            this.match()
          else if(current == "xpath")
            this.xpath()
          else if(current == "at")
            this.at()
          else if(current == "none")
            this.none()
        }
      },

      css:function(event)
      {
        $("#selector").html("css")
        $("#selector-input").removeAttr("disabled").val(_SelectorModel.get("css"))
        _SelectorModel.set("current","css")
        BrowserAutomationStudio_TestPathInternal();
      },

      match:function(event)
      {
        $("#selector").html("match")
        $("#selector-input").removeAttr("disabled").val(_SelectorModel.get("match"))
        _SelectorModel.set("current","match")
        BrowserAutomationStudio_TestPathInternal();
      },

      xpath:function(event)
      {
        $("#selector").html("xpath")
        $("#selector-input").removeAttr("disabled").val(_SelectorModel.get("xpath"))
        _SelectorModel.set("current","xpath")
        BrowserAutomationStudio_TestPathInternal();
      },

      at:function(event)
      {
        $("#selector").html("at")
        $("#selector-input").removeAttr("disabled").val(_SelectorModel.get("mousex") + ", " + _SelectorModel.get("mousey"))
        _SelectorModel.set("current","at")
        BrowserAutomationStudio_TestPathInternal();
      },

      none:function(event)
      {
        $("#selector").html("none")
        $("#selector-input").attr("disabled","disabled").val("")

        _SelectorModel.set("current","none")
        BrowserAutomationStudio_TestPathInternal();
      },

      clickexecutetype:function(event)
      {
          $("#executetype button").removeClass("btn-info")
          $("#executetype button").addClass("btn-default")
          $(event.target).removeClass("btn-default")
          $(event.target).addClass("btn-info")
      },

      specialletter: function(event)
      {
        InsertAtCaret("TypeData","<" + $(event.target).html() + ">");
      },

      resaddstarttrigger: function(event)
      {
        this.currentInputResource = $(event.target).closest("a").attr("data-result-target")

        $('#RecourseModal').modal('show')   

      },

      rescontinue: function(event)
      {
        $('#RecourseModal').find(".step-2").show()
        $('#RecourseModal').find(".step-1").hide()

      },

      resaddstart: function(event)
      {

        $('#RecourseModal').find(".step-1").show()
        $('#RecourseModal').find(".step-2").hide()


        var json = _ResourceCollection.toJSON();
        $('#RecourseName').html("")
        if(json.length == 0)
        {
          $("#NoResources").show()
          $("#RecourseControls").hide()
          $(".rescontinue").hide()
        }else
        {
          $("#NoResources").hide()
          $("#RecourseControls").show()
          $("#ResourceReuse").prop('checked', true);
          $("#ResourceDontDie").prop('checked', false);
          $(".rescontinue").show()
          json = jsort(json);
          for(var i = 0;i<json.length;i+=1)
          {
            $('#RecourseName')
             .append($("<option></option>")
             .attr("value",json[i]["name"])
             .text(json[i]["name"] + ": " + json[i]["description"]));
           }
         }

        $('#RecourseName').focus()
      },

      varaddstarttrigger: function(event)
      {
        this.currentInputVariable = $(event.target).closest("a").attr("data-result-target")
        this.disable_locals = $(event.target).closest("a").attr("disable_locals") == "true"
        this.disable_globals = $(event.target).closest("a").attr("disable_globals") == "true"


        $('#VariableModal').modal('show');
      },

      varaddstart: function(event)
      {
        //console.log("varaddstart")

        var json = _VariableCollection.toJSON();
        var json2 = _GlobalVariableCollection.toJSON();
        var total = 0


        
        if(!this.disable_locals)
        {
          total += json.length  
        }        

        if(!this.disable_globals)
        {
          total += json2.length
        }

        $('#VariableName').html("")
        if(total == 0)
        {
          $("#NoVariable").show()
          $("#VariableName").hide()
          $(".varok").hide()

        }else
        {
          $("#NoVariable").hide()
          $("#VariableName").show()
          $(".varok").show()
          if(!this.disable_locals)
          {
            json = jsort(json);
            for(var i = 0;i<json.length;i+=1)
            {
              $('#VariableName')
               .append($("<option></option>")
               .attr("value",json[i]["name"])
               .text(json[i]["name"]));
            }
          }
          if(!this.disable_globals)
          {
            json2 = jsort(json2);
            for(var i = 0;i<json2.length;i+=1)
            {
              $('#VariableName')
               .append($("<option></option>")
               .attr("value",json2[i]["name"])
               .attr("isglobal","true")
               .text(tr("Global: ") + json2[i]["name"]));
            }
          }
         }



        $('#VariableName').focus()
      },

      funcaddstart: function(event)
      {
        var json = _FunctionCollection.toJSON();

        $('#FunctionNameInput').html("")
        if(json.length == 0)
        {
          $("#NoFunctionFound").show()
          $("#FunctionNameInput").hide()
          $(".funcok").hide()

        }else
        {
          $("#NoFunctionFound").hide()
          $("#FunctionNameInput").show()
          $(".funcok").show()
          for(var i = 0;i<json.length;i+=1)
          {
            json = jsort(json);
            $('#FunctionNameInput')
             .append($("<option></option>")
             .attr("value",json[i]["name"])
             .text(json[i]["name"]));
           }
         }

        $('#FunctionNameInput').focus()
        this.currentInputVariable = $(event.relatedTarget).attr("data-result-target")

      },

      labeladdstart: function(event)
      {
        var json = _LabelCollection.toJSON();

        $('#LabelNameInput').html("")
        if(json.length == 0)
        {
          $("#NoLabelFound").show()
          $("#LabelNameInput").hide()
          $(".labelok").hide()

        }else
        {
          $("#NoLabelFound").hide()
          $("#LabelNameInput").show()
          $(".labelok").show()
          json = jsort(json);
          for(var i = 0;i<json.length;i+=1)
          {
            $('#LabelNameInput')
             .append($("<option></option>")
             .attr("value",json[i]["name"])
             .text(json[i]["name"]));
           }
         }

        $('#LabelNameInput').focus()
        this.currentInputLabel = $(event.relatedTarget).attr("data-result-target")

      },



      resadd: function(event)
      {
        var el = $(this.currentInputResource)
        var isnumber = $(this.currentInputResource + "_number:visible").length > 0

        var res = $("#RecourseName").val();
        if(!$("#ResourceReuse").is(':checked'))
          res+="|notreuse";
        if($("#ResourceDontDie").is(':checked'))
          res+="|onlyfail";

        if(isnumber)
        {
          el.closest(".input-group").find(".selector").html("expression")
          el.closest(".input-group").find(".input_selector_number").hide()
          el.closest(".input-group").find(".input_selector_string").show()
          
          el.val("{{" + res + "}}")
        }else
        {
          var name = $("#RecourseName").val();
          if(name.length > 0)
          {
            if(el.is("[data-resource-constructor]"))
            {
              el.val(res)
            }else
            {
              var start = 0
              try{
                start = el.val().length
                start = cursorposition(el[0]).start
              }catch(e){}
              var val = el.val()
              val = val.slice(0, start) + "{{" + res + "}}" + val.slice(start)
              el.val(val)
            }
          }
        }
        if(this.currentInputResource == "#selector-input")
        {
          BrowserAutomationStudio_TestPathInternal();
        }

      },

      varadd: function(event)
      {

        var el = $(this.currentInputVariable)
        var isnumber = $(this.currentInputVariable + "_number:visible").length > 0
        var isglobal = $("#VariableName option:selected").attr("isglobal") == "true"

        if(isnumber)
        {
          el.closest(".input-group").find(".selector").html("expression")
          el.closest(".input-group").find(".input_selector_number").hide()
          el.closest(".input-group").find(".input_selector_string").show()
          if(isglobal)
          {
            el.val("[[GLOBAL:" + $("#VariableName").val() + "]]")
          }else
          {
            el.val("[[" + $("#VariableName").val() + "]]")  
          }
          
        }else
        {

          var name = $("#VariableName").val();
          if(name.length > 0)
          {
            if(!el.is("[data-variable-constructor]"))
            {

              var insert = ""
              if(isglobal)
              {
                insert = "[[GLOBAL:" + $("#VariableName").val() + "]]"
              }else
              {
                insert = "[[" + $("#VariableName").val() + "]]"
              }

              var start = 0
              try{
                start = el.val().length
                start = cursorposition(el[0]).start
              }catch(e){}
              var val = el.val()
              val = val.slice(0, start) + insert + val.slice(start)

              el.val(val)
            }else
            {
              if(el.is("[data-append-array]"))
              {
                if(el.val().length == 0)
                  el.val($("#VariableName").val())
                else
                  el.val(el.val() + "," + $("#VariableName").val())
              }else
              {
                el.val($("#VariableName").val())
              }
            }
          }
        }
        if(this.currentInputVariable == "#selector-input")
        {
          BrowserAutomationStudio_TestPathInternal();
        }

      },

      funcadd: function(event)
      {
        var el = $(this.currentInputVariable)

        var name = $("#FunctionNameInput").val();
        if(name.length > 0)
        {
          el.val($("#FunctionNameInput").val())
        }
      },

      labeladd: function(event)
      {
        var el = $(this.currentInputLabel)

        var name = $("#LabelNameInput").val();
        if(name.length > 0)
        {
          el.val($("#LabelNameInput").val())
        }
      },

      timeoutadd: function(event)
      {
        var timeout_value = $("#TimeoutValue").val()

        $("#use-timeout").attr("data-value", (typeof(timeout_value) != "undefined" && timeout_value > 0) ? timeout_value : "0")
                        .attr("class", ((typeof(timeout_value) != "undefined" && timeout_value > 0) ? "" : "use-timeout-disabled") + " trtitle")
                        .attr("data-enabled", (typeof(timeout_value) != "undefined" && timeout_value > 0) ? "true" : "false")

        $("#timeout-val").html((typeof(timeout_value) != "undefined" && timeout_value > 0) ? ("" + timeout_value) : "")
        if(typeof(timeout_value) != "undefined" && timeout_value > 0)
        {
         $("#timeout-is-default").hide()
        }else
        {
          $("#timeout-is-default").show()
        }


      },

      timeoutdefault: function(event)
      {
        $("#TimeoutValue").val(0)

        this.timeoutadd(null);

      },

      accept: function()
      {
          var State = this.model.get("state");
          var loader = new ResourceLoader();

          var action = $("#executetype .btn-info").attr("data-action")

          BrowserAutomationStudio_LastExecuteType = action

          if(typeof(action) == "undefined")
          {
            action = 2
          }else if(action == "execute")
          {
            action = 0
          }else if(action == "add")
          {
            action = 1
          }else if(action == "executeandadd")
          {
            action = 2
          }


          var DisableIfAdd = true
          if(_GobalModel.get("isedit"))
          {
            DisableIfAdd = action == 1
            action = 1
          }




          if(State == "load")
          {
            var val = GetInputConstructorValue("LoadUrl",loader)

            if(val["original"].length > 0)
            {
               try{
                var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({url:val["updated"],notinstant:BrowserAutomationStudio_UsesWaitCode()})
                code = Normalize(code,0)

                BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
              }catch(e)
              {}
            }else
            {
              Invalid("Url is empty");
              return;
            }
          }else if(State == "httpclientxpathxml")
          {

            var Save = this.$el.find("#Save").val().toUpperCase();
            var Value = GetInputConstructorValue("Value", loader);
            var fail = $("#Check").is(':checked')


            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
            if(Value["original"].length == 0)
            {
              Invalid("Query is empty");
              return;
            }
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save,value: Value["updated"], fail:fail})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "httpclientxpathxmllist")
          {

            var Save = this.$el.find("#Save").val().toUpperCase();
            var Value = GetInputConstructorValue("Value", loader);

            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
            if(Value["original"].length == 0)
            {
              Invalid("Query is empty");
              return;
            }
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save,value: Value["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "waitelement")
          {
             var CheckIsvisible = $("#Check").is(':checked')
             try{
              var path = GetPath(loader,true,CheckIsvisible)
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({waiter: path["waiter"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "httpclientxpathtext")
          {

            var Save = this.$el.find("#Save").val().toUpperCase();
            var Value = GetInputConstructorValue("Value", loader);
            var fail = $("#Check").is(':checked')


            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
            if(Value["original"].length == 0)
            {
              Invalid("Query is empty");
              return;
            }
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save,value: Value["updated"], fail:fail})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "httpclientxpathtextlist")
          {

            var Save = this.$el.find("#Save").val().toUpperCase();
            var Value = GetInputConstructorValue("Value", loader);

            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
            if(Value["original"].length == 0)
            {
              Invalid("Query is empty");
              return;
            }
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save,value: Value["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "httpclientxpathcount")
          {

            var Save = this.$el.find("#Save").val().toUpperCase();
            var Value = GetInputConstructorValue("Value", loader);

            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
            if(Value["original"].length == 0)
            {
              Invalid("Query is empty");
              return;
            }
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save,value: Value["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "httpclientxpathexists")
          {

            var Save = this.$el.find("#Save").val().toUpperCase();
            var Value = GetInputConstructorValue("Value", loader);

            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
            if(Value["original"].length == 0)
            {
              Invalid("Query is empty");
              return;
            }
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save,value: Value["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "httpclientfailonerror")
          {
            var Value = GetInputConstructorValue("SetFailed",loader)

            if(Value["original"].length <= 0)
            {
              Invalid("Value is empty");
              return;
            }

             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({value:Value["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          
            
          }else if(State == "httpclienturl")
          {

            var Save = this.$el.find("#Save").val().toUpperCase();

            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "httpclientcontent")
          {

            var Save = this.$el.find("#Save").val().toUpperCase();

            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "httpclientiserror")
          {

            var Save = this.$el.find("#Save").val().toUpperCase();

            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "httpclientgeterrorstring")
          {

            var Save = this.$el.find("#Save").val().toUpperCase();

            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "httpclientstatus")
          {

            var Save = this.$el.find("#Save").val().toUpperCase();

            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "httpclientgetheader")
          {

            var Save = this.$el.find("#Save").val().toUpperCase();
            var Value = GetInputConstructorValue("Value", loader);

            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
            if(Value["original"].length == 0)
            {
              Invalid("Header is empty");
              return;
            }
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save,value: Value["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "httpclientsetheader")
          {
            var Name = GetInputConstructorValue("Name",loader)
            var Value = GetInputConstructorValue("Value",loader)

            if(Name["original"].length <= 0)
            {
              Invalid("Name is empty");
              return;
            }
            
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({name:Name["updated"],value:Value["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("" , BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
            
          }else if(State == "httpclientgetcookiesforurl")
          {

            var Save = this.$el.find("#Save").val().toUpperCase();
            var Value = GetInputConstructorValue("Value", loader);

            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
            if(Value["original"].length == 0)
            {
              Invalid("Url is empty");
              return;
            }
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save,value: Value["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "httpclientrestorecookies")
          {
            var Value = GetInputConstructorValue("Value",loader)

             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({value:Value["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
            
          }else if(State == "httpclientsavecookies")
          {

            var Save = this.$el.find("#Save").val().toUpperCase();

            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
            
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "httpclientclearheader")
          {

             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("" , BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
            
          }else if(State == "httpclientget")
          {
            var Value = GetInputConstructorValue("Value",loader)
            var Method = GetInputConstructorValue("Method",loader)
            var follow = $("#Check").is(':checked')

            if(Value["original"].length <= 0)
            {
              Invalid("Url is empty");
              return;
            }

            if(Method["original"].length <= 0)
            {
              Invalid("Method is empty");
              return;
            }
            
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({follow:follow,value:Value["updated"],method:Method["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          
            
          }else if(State == "httpclientpost")
          {
            var Value = GetInputConstructorValue("Value",loader)
            var follow = $("#Check").is(':checked')
            var Encoding = GetInputConstructorValue("Encoding",loader)
            var Method = GetInputConstructorValue("Method",loader)
            var ContentType = GetInputConstructorValue("ContentType",loader)
            var PostDataArray = GetInputConstructorValue("PostDataArray",loader)
            

            if(Value["original"].length <= 0)
            {
              Invalid("Url is empty");
              return;
            }

            if(Encoding["original"].length <= 0)
            {
              Invalid("Encoding is empty");
              return;
            }

            if(Method["original"].length <= 0)
            {
              Invalid("Method is empty");
              return;
            }

            if(ContentType["original"].length <= 0)
            {
              Invalid("ContentType is empty");
              return;
            }



             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({
                follow:follow,
                value:Value["updated"],
                contenttype:ContentType["updated"],
                encoding:Encoding["updated"],
                method:Method["updated"],
                params:"[" + PostDataArray["updated"] + "]"
              })
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          
            
          }else if(State == "parseline")
          {
            var Value = GetInputConstructorValue("Value",loader)
            var List = $("#VariablesList").val().toUpperCase()
            
            if(Value["original"].length <= 0)
            {
              Invalid("Value is empty");
              return;
            }

            if(List.length <= 0)
            {
              Invalid("Variables list is empty");
              return;
            }

            List = List.replace(/\s/g,"")
            List = List.split(",")
            List = _.compact(List);
            if(List.length > 0)
            {
              /*List[0] = List[0].replace(/[\\[\\]]/g,"")
              List[List.length - 1] = List[List.length - 1].replace(/[\\[\\]]/g,"")*/
            }else
            {
              Invalid("Variables list is empty");
              return; 
            }

             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({list:List,value:Value["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          
            
          }else if(State == "httpclientproxy")
          {
              var ProxyText = GetInputConstructorValue("ProxyText",loader)
              var ProxyType = GetInputConstructorValue("ProxyType", loader)
              var ProxyLogin = GetInputConstructorValue("ProxyLogin",loader)
              if(ProxyLogin["updated"] == "")
                ProxyLogin["updated"] = '""'
              var ProxyPassword = GetInputConstructorValue("ProxyPassword",loader)
              if(ProxyPassword["updated"] == "")
                ProxyPassword["updated"] = '""'
              var IsEmptyProxy = false
              if(ProxyText["updated"] == "")
              {
                ProxyText["updated"] = '""'
                IsEmptyProxy = true
              }

              try{
                var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({ProxyText:ProxyText["updated"], ProxyType:ProxyType["updated"],ProxyLogin:ProxyLogin["updated"],ProxyPassword:ProxyPassword["updated"]})
                code = Normalize(code,0)
                BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
              }catch(e){}


          }
          else if(State == "httpclientreset")
          {
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "solverfailed")
          {
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }
          else if(State == "httpclientdownload")
          {
            var Value = GetInputConstructorValue("Value",loader)
            var File = GetInputConstructorValue("File",loader)


            if(Value["original"].length <= 0)
            {
              Invalid("Url is empty");
              return;
            }
            if(File["original"].length <= 0)
            {
              Invalid("File is empty");
              return;
            }
            
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({file:File["updated"],value:Value["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          
            
          }else if(State == "emailpull")
          {

            var Save = this.$el.find("#Save").val().toUpperCase();
            var Value = GetInputConstructorValue("Value", loader);
            
            var List = $("#VariablesList").val().toUpperCase()
            List = List.replace(/\s/g,"")
            List = List.split(",")
            List = _.compact(List);

            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
            if(Value["original"].length == 0)
            {
              Invalid("Eamil id is empty");
              return;
            }
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({link_list:List,variable:"VAR_" + Save,value: Value["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "emailsearchfirst")
          {
            var Sender = GetInputConstructorValue("Sender",loader)
            var Subject = GetInputConstructorValue("Subject",loader)
            var Body = GetInputConstructorValue("Body",loader)
            var Save = this.$el.find("#Save").val().toUpperCase();

            var List = $("#VariablesList").val().toUpperCase()
            List = List.replace(/\s/g,"")
            List = List.split(",")
            List = _.compact(List);


            if(Sender["original"].length <= 0)
            {
              Sender["updated"] = '""';
            }
            if(Subject["original"].length <= 0)
            {
              Subject["updated"] = '""';
            }
            if(Body["original"].length <= 0)
            {
              Body["updated"] = '""';
            }
            
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({link_list:List,variable:"VAR_" + Save,sender:Sender["updated"],subject:Subject["updated"],body:Body["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          
            
          }else if(State == "emailsearchall")
          {
            var Sender = GetInputConstructorValue("Sender",loader)
            var Subject = GetInputConstructorValue("Subject",loader)
            var Body = GetInputConstructorValue("Body",loader)
            var Save = this.$el.find("#Save").val().toUpperCase();


            if(Sender["original"].length <= 0)
            {
              Sender["updated"] = '""';
            }
            if(Subject["original"].length <= 0)
            {
              Subject["updated"] = '""';
            }
            if(Body["original"].length <= 0)
            {
              Body["updated"] = '""';
            }
            
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save,sender:Sender["updated"],subject:Subject["updated"],body:Body["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          
            
          }else if(State == "emailsettings")
          {
            var Host = GetInputConstructorValue("Host",loader)
            var Port = GetInputConstructorValue("Port",loader)
            var Username = GetInputConstructorValue("Username",loader)
            var Password = GetInputConstructorValue("Password",loader)
            var Inbox = GetInputConstructorValue("Inbox",loader)
            var Secure = $("#Select").val()

            if(Host["original"].length <= 0)
            {
              Invalid("Host is empty");
              return;
            }
            if(Port["original"].length <= 0)
            {
              Invalid("Port is empty");
              return;
            }
            if(Inbox["original"].length <= 0)
            {
              Invalid("Inbox is empty");
              return;
            }
            if(Username["original"].length <= 0)
            {
              Username["updated"] = '""';
            }
            if(Password["original"].length <= 0)
            {
              Password["updated"] = '""';
            }
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({host:Host["updated"], username:Username["updated"], password: Password["updated"], port:Port["updated"], encryption:"\"" + je(Secure) + "\"", inbox:Inbox["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("" , BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "emaillength")
          {
            var Save = this.$el.find("#Save").val().toUpperCase();

            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
            
          }else if(State == "globalset")
          {
            var Name = this.$el.find("#Name").val().toUpperCase();
            var Value = GetInputConstructorValue("Value",loader)

            if(Name.length <= 0)
            {
              Invalid("Key is empty");
              return;
            }
            if(Value["original"].length <= 0)
            {
              Invalid("Value is empty");
              return;
            }
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({key:JSON.stringify(Name),value:Value["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "globalget")
          {

            var Save = this.$el.find("#Save").val().toUpperCase();
            var Name = GetInputConstructorValue("Name", loader);

            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
            if(Name["original"].length == 0)
            {
              Invalid("Key is empty");
              return;
            }
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save,key: Name["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "base64")
          {
            var Save = this.$el.find("#Save").val().toUpperCase();
            var Value = GetInputConstructorValue("Value", loader);
            var encode = $("#Select").val() == "encode"

            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
            if(Value["original"].length == 0)
            {
              Invalid("Data is empty");
              return;
            }
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save,value: Value["updated"], encode: encode})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "result")
          {
            var Value = GetInputConstructorValue("Value",loader)
            var num = $("#Select").val()

            if(Value["original"].length <= 0)
            {
              Invalid("Data is empty");
              return;
            }
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({number:parseInt(num)-1,value:Value["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
            
          }else if(State == "cachemaskallow")
          {
            var Value = GetInputConstructorValue("Value",loader)

            if(Value["original"].length <= 0)
            {
              Invalid("Mask is empty");
              return;
            }
            
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({value:Value["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "cachemaskdeny")
          {
            var Value = GetInputConstructorValue("Value",loader)

            if(Value["original"].length <= 0)
            {
              Invalid("Mask is empty");
              return;
            }
            
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({value:Value["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "requestmaskallow")
          {
            var Value = GetInputConstructorValue("Value",loader)

            if(Value["original"].length <= 0)
            {
              Invalid("Mask is empty");
              return;
            }
            
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({value:Value["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "requestmaskdeny")
          {
            var Value = GetInputConstructorValue("Value",loader)

            if(Value["original"].length <= 0)
            {
              Invalid("Mask is empty");
              return;
            }
            
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({value:Value["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "cleardata")
          {
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "loadcookiesfrombrowser")
          {
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "loadcookiesfromhttpclient")
          {
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "closebrowser")
          {
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "openbrowser")
          {
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "clearmasks")
          {
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "getstatus")
          {
            var Value = GetInputConstructorValue("Value",loader)
            var Save = this.$el.find("#Save").val().toUpperCase();

            if(Value["original"].length <= 0)
            {
              Invalid("Mask is empty");
              return;
            }
            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
            
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save,value:Value["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "isloaded")
          {
            var Value = GetInputConstructorValue("Value",loader)
            var Save = this.$el.find("#Save").val().toUpperCase();


            if(Value["original"].length <= 0)
            {
              Invalid("Mask is empty");
              return;
            }
            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
            
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save,value:Value["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "getfromcache")
          {
            var Value = GetInputConstructorValue("Value",loader)
            var Save = this.$el.find("#Save").val().toUpperCase();

            if(Value["original"].length <= 0)
            {
              Invalid("Mask is empty");
              return;
            }
            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }

            var base64 = $("#Check").is(':checked')
            
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save,value:Value["updated"],base64:base64})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "html")
          {
            var Save = this.$el.find("#Save").val().toUpperCase();

            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
            
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "getcookiesforurl")
          {

            var Save = this.$el.find("#Save").val().toUpperCase();
            var Value = GetInputConstructorValue("Value", loader);
            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
            if(Value["original"].length == 0)
            {
              Invalid("Url is empty");
              return;
            }
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save,value: Value["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "restorecookies")
          {
            var Value = GetInputConstructorValue("Value",loader)

            if(Value["updated"].length <= 0)
            {
              Value["updated"] = "\"\""
            }

             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({value:Value["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
            
          }else if(State == "savecookies")
          {
            var Save = this.$el.find("#Save").val().toUpperCase();
            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
            
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "openfile")
          {
            var Value = GetInputConstructorValue("Value",loader)

            if(Value["original"].length <= 0)
            {
              Invalid("File is empty");
              return;
            }

             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({value:Value["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
            
          }else if(State == "promptresult")
          {
            var Value = GetInputConstructorValue("Value",loader)

            if(Value["original"].length <= 0)
            {
              Invalid("Value is empty");
              return;
            }

             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({value:Value["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
            
          }else if(State == "httpauth")
          {
            var Login = GetInputConstructorValue("Login",loader)
            var Password = GetInputConstructorValue("Password",loader)
            

            if(Login["original"].length <= 0)
            {
              Invalid("Login is empty");
              return;
            }

            if(Password["original"].length <= 0)
            {
              Invalid("Password is empty");
              return;
            }

             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({login:Login["updated"],password:Password["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
            
          }else if(State == "javascript")
          {
            loader.SetIsJsonStringify(true);
            var Save = this.$el.find("#Save").val().toUpperCase();
            var Value = GetInputConstructorValue("Value", loader);

            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
            if(Value["original"].length == 0)
            {
              Invalid("Javascript is empty");
              return;
            }
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save,value: Value["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "onloadjavascript")
          {
            var Value = GetInputConstructorValue("Value", loader);

             try{
              var TargetCode = BrowserAutomationStudio_GetTargetCode(loader)
              var code = loader.GetAdditionalData() + TargetCode + _.template($('#' + State + "_code").html())({value: Value["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "reset")
          {
             try{

              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({reset:$("#Check").is(':checked')})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "solvecaptcha")
          {
            
            var Method = GetInputConstructorValue("Method", loader);
            var Save = this.$el.find("#Save").val().toUpperCase();
            var Value = GetInputConstructorValue("Value", loader);
            var Antigate = GetInputConstructorValue("Antigate", loader);
            var Server = GetInputConstructorValue("Server", loader);

            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
            if(Value["original"].length == 0)
            {
              Invalid("Captcha is empty");
              return;
            }
            if(Method["original"].length == 0)
            {
              Invalid("Method is empty");
              return;
            }

             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save,value: Value["updated"],method: Method["updated"], antigate: Antigate["updated"], serverurl: Server["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "replacestring")
          {
            
            var Value = GetInputConstructorValue("Value", loader);
            var ReplaceFrom = GetInputConstructorValue("ReplaceFrom", loader);
            var ReplaceTo = GetInputConstructorValue("ReplaceTo", loader);
            var Save = this.$el.find("#Save").val().toUpperCase();
            
            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
            if(Value["original"].length == 0)
            {
              Invalid("Value is empty");
              return;
            }
            if(ReplaceFrom["original"].length == 0)
            {
              Invalid("ReplaceFrom is empty");
              return;
            }

             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save,value: Value["updated"],from: ReplaceFrom["updated"], to: ReplaceTo["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "randomstring")
          {
            
            var AllowedChars = GetInputConstructorValue("AllowedChars", loader);
            var Length = GetInputConstructorValue("Length", loader);
            var Save = this.$el.find("#Save").val().toUpperCase();
            
            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
            if(AllowedChars["original"].length == 0)
            {
              Invalid("AllowedChars is empty");
              return;
            }
            if(Length["original"].length == 0)
            {
              Invalid("Length is empty");
              return;
            }

             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save,chars: AllowedChars["updated"],length: Length["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "randomint")
          {
            
            var MinValue = GetInputConstructorValue("MinValue", loader);
            var MaxValue = GetInputConstructorValue("MaxValue", loader);
            var Save = this.$el.find("#Save").val().toUpperCase();
            
            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
            if(MinValue["original"].length == 0)
            {
              Invalid("MinValue is empty");
              return;
            }
            if(MaxValue["original"].length == 0)
            {
              Invalid("MaxValue is empty");
              return;
            }

             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save,min: MinValue["updated"],max: MaxValue["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "template")
          {
            
            var Template;
            if($("#Check").is(':checked'))
            {
              Template = GetInputConstructorValue("Template", loader)["updated"];
            }else
            {
              Template = "\"" + je($("#Template").val()) + "\"";
            }
            var Save = this.$el.find("#Save").val().toUpperCase();
            
            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
            
            if($("#Template").val().length == 0)
            {
              Invalid("Template is empty");
              return;
            }

             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save,template: Template})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "setheader")
          {
            var Name = GetInputConstructorValue("Name",loader)
            var Value = GetInputConstructorValue("Value",loader)

            if(Name["original"].length <= 0)
            {
              Invalid("Name is empty");
              return;
            }

            
             try{
              var TargetCode = BrowserAutomationStudio_GetTargetCode(loader)
              var code = loader.GetAdditionalData() + TargetCode + _.template($('#' + State + "_code").html())({name:Name["updated"],value:Value["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("" , BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          
            
          }else if(State == "custom")
          {
            var val = GetInputConstructorValue("Code",loader)

            if(val["original"].length > 0)
            {
               try{
                var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({code:val["updated"]})
                code = Normalize(code,0)
                BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
              }catch(e)
              {}
            }else
            {
              Invalid("Code is empty");
              return;
            }
          }else if(State == "break")
          {

             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({})

              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, 1, false);

            }catch(e)
            {}

          }else if(State == "continue")
          {
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({})

              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, 1, false);

            }catch(e)
            {}

          }else if(State == "success")
          {
            var val = GetInputConstructorValue("SuccessMessage",loader)

             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({message:val["updated"]})

              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, 1, false);

            }catch(e)
            {}

          }else if(State == "fail")
          {
            var val = GetInputConstructorValue("FailMessage",loader)
            var Check = $("#Check").is(':checked')


             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({message:val["updated"],dontrestart: Check})

              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, 1, false);

            }catch(e)
            {}

          }else if(State == "die")
          {
            var val = GetInputConstructorValue("FailMessage",loader)
            var Check = $("#Check").is(':checked')


             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({message:val["updated"],instant: Check})

              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, 1, false);

            }catch(e)
            {}

          }else if(State == "label")
          {
            var val = GetInputConstructorValue("Label",loader)
            if(val["original"].length <= 0)
            {
                Invalid("Label is empty");
                return;
            }

             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({label:val["updated"]})

              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, 1, false);

            }catch(e)
            {}

          }else if(State == "goto")
          {
            var val = $("#LabelName").val()
            if(val.length <= 0)
            {
                Invalid("Label is empty");
                return;
            }
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({label:JSON.stringify(val)})

              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, 1, false);

            }catch(e)
            {}

          }else if(State == "sleep")
          {
            if($("#sleeprandom").is(':checked'))
            {
              var from = GetInputConstructorValue("sleepfrom",loader)
              var to = GetInputConstructorValue("sleepto",loader)
              if(from["original"].length <= 0)
              {
                Invalid("Sleep from time is empty");
                return;
              }

              if(to["original"].length <= 0)
              {
                Invalid("Sleep to time is empty");
                return;
              }


              try{
                var code = loader.GetAdditionalData() + _.template($('#' + State + "_fromto_code").html())({from:from["updated"], to:to["updated"]})
                code = Normalize(code,0)
                BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
              }catch(e){}
            }else
            {
              var t = GetInputConstructorValue("sleepfromto",loader)

              if(t["original"].length <= 0)
              {
                Invalid("Sleep time is empty");
                return;
              }

              try{
                var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({t:t["updated"]})
                code = Normalize(code,0)
                BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
              }catch(e){}
            }

          }else if(State == "proxy")
          {
              var ProxyText = GetInputConstructorValue("ProxyText",loader)
              var ProxyType = GetInputConstructorValue("ProxyType", loader)
              var ProxyLogin = GetInputConstructorValue("ProxyLogin",loader)
              if(ProxyLogin["updated"] == "")
                ProxyLogin["updated"] = '""'
              var ProxyPassword = GetInputConstructorValue("ProxyPassword",loader)
              if(ProxyPassword["updated"] == "")
                ProxyPassword["updated"] = '""'
              var IsEmptyProxy = false
              if(ProxyText["updated"] == "")
              {
                ProxyText["updated"] = '""'
                IsEmptyProxy = true
              }
              /*if(ProxyText["original"].length <= 0)
              {
                Invalid("Proxy is empty");
                return;
              }*/

              try{
                var TargetCode = BrowserAutomationStudio_GetTargetCode(loader)
                var code = loader.GetAdditionalData() + TargetCode + _.template($('#' + State + "_code").html())({ProxyText:ProxyText["updated"], ProxyType:ProxyType["updated"],ProxyLogin:ProxyLogin["updated"],ProxyPassword:ProxyPassword["updated"]})
                code = Normalize(code,0)
                BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
              }catch(e){}


          }else if(State == "emailproxy")
          {
              var ProxyText = GetInputConstructorValue("ProxyText",loader)
              var ProxyType = GetInputConstructorValue("ProxyType", loader)
              var ProxyLogin = GetInputConstructorValue("ProxyLogin",loader)
              if(ProxyLogin["updated"] == "")
                ProxyLogin["updated"] = '""'
              var ProxyPassword = GetInputConstructorValue("ProxyPassword",loader)
              if(ProxyPassword["updated"] == "")
                ProxyPassword["updated"] = '""'
              var IsEmptyProxy = false
              if(ProxyText["updated"] == "")
              {
                ProxyText["updated"] = '""'
                IsEmptyProxy = true
              }
              /*if(ProxyText["original"].length <= 0)
              {
                Invalid("Proxy is empty");
                return;
              }*/

              try{
                var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({ProxyText:ProxyText["updated"], ProxyType:ProxyType["updated"],ProxyLogin:ProxyLogin["updated"],ProxyPassword:ProxyPassword["updated"]})
                code = Normalize(code,0)
                BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
              }catch(e){}


          }else if(State == "waitload" || State == "waiturl" || State == "waitcontent" || State == "waitcss")
          {
            var val = GetInputConstructorValue("Wait",loader)

            if(val["original"].length > 0)
            {
               try{
                var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({waiter:val["updated"]})
                code = Normalize(code,0)
                BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
              }catch(e)
              {}
            }else
            {
              Invalid("Waiter is empty");
              return;
            }
          }else if(State == "waitfullload")
          {
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "if")
          {
            var val = GetInputConstructorValue("IfExpression",loader)
            var ElseEnabled = $("#IfElse").is(":checked")
            if(val["original"].length > 0)
            {

               try{
                if(!ElseEnabled)
                {
                  var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({expression:val["updated"], do_delete: ""})
                  code = Normalize(code,0)
                  BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, 1, false);
                }else
                {
                  var v = "IF_ELSE_EXPRESSION_" + Math.floor(Math.random() * (999999 - 100000) + 100000)
                  var slave_id = Math.floor(Math.random() * (1000000000 - 100)) + 100
                  var master_id = Math.floor(Math.random() * (1000000000 - 100)) + 100

                  if(_GobalModel.get("isedit"))
                  {
                    if(CurrentDat && CurrentDat["slave"])
                      slave_id = parseInt(CurrentDat["slave"])

                    if(CurrentDat && CurrentDat["master"])
                      master_id = parseInt(CurrentDat["master"])

                    if(CurrentDat && CurrentDat["if_var"])
                      v = CurrentDat["if_var"]
                  }


                  var code = loader.GetAdditionalData() + "\n" +  v + " = " + val["updated"] + ";\n"

 

                  code += _.template($('#' + State + "_code").html())({expression:v, do_delete: ""})
                  code = Normalize(code,0)
                  BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls({role: "master", slave: slave_id, master: master_id, if_var: v}) + code, 1, false, master_id.toString());

                  if(!_GobalModel.get("isedit"))
                  {
                    code = _.template($('#' + State + "_code").html())({expression:"!" + v, do_delete: v})
                    code = Normalize(code,0)
                    BrowserAutomationStudio_Append("Else", BrowserAutomationStudio_SaveControls({role: "slave", slave: slave_id, master: master_id, if_var: v}) + code, 1, false, slave_id.toString());
                  }
                }
              }catch(e)
              {}
            }else
            {
              Invalid("Expression is empty");
              return;
            }
          }else if(State == "while")
          {
            var val = GetInputConstructorValue("WhileExpression",loader)
            if(val["original"].length > 0)
            {
               try{
                var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({expression:val["updated"],additional:loader.GetAdditionalData()})
                code = Normalize(code,0)
                BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, 1, false);
              }catch(e)
              {}
            }else
            {
              Invalid("Expression is empty");
              return;
            }
          }else if(State == "for")
          {
            var from = GetInputConstructorValue("ForFrom",loader)
            var to = GetInputConstructorValue("ForTo",loader)
            if(from["original"].length == 0)
            {
              Invalid("From is empty");
              return;
            }
            if(to["original"].length == 0)
            {
              Invalid("To is empty");
              return;
            }
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({expression_from:from["updated"],expression_to:to["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, 1, false);
            }catch(e)
            {}
          }else if(State == "ignoreerrors")
          {
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, 1, false);
            }catch(e)
            {}
          }else if(State == "foreach")
          {
            var ForArray = GetInputConstructorValue("ForArray",loader)
            if(ForArray["original"].length == 0)
            {
              Invalid("Array is empty");
              return;
            }
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({for_array:ForArray["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, 1, false);
            }catch(e)
            {}
          }else if(State == "resize")
          {
            var width = GetInputConstructorValue("ResizeX",loader)
            var height = GetInputConstructorValue("ResizeY",loader)

            if(width["original"].length == 0)
            {
              Invalid("Width is empty");
              return;
            }


            if(height["original"].length == 0)
            {
              Invalid("Height is empty");
              return;
            }

             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({width:width["updated"],height:height["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "type")
          {
            var TypeData = GetInputConstructorValue("TypeData",loader);
            var TypeInterval = GetInputConstructorValue("TypeInterval",loader);

            if(TypeInterval["original"].length == 0)
            {
              Invalid("interval is empty");
              return;
            }
            if(TypeData["original"].length == 0)
            {
              Invalid("Type data is empty");
              return;
            }

            try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({text:TypeData["updated"],interval:TypeInterval["updated"]}) + BrowserAutomationStudio_GetWaitCode()
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "typeelement")
          {
            var TypeData = GetInputConstructorValue("TypeData",loader);
            var TypeInterval = GetInputConstructorValue("TypeInterval",loader);
            var Check = $("#Check").is(':checked')

            if(TypeInterval["original"].length == 0)
            {
              Invalid("interval is empty");
              return;
            }
            if(TypeData["original"].length == 0)
            {
              Invalid("Type data is empty");
              return;
            }

            try{
              var path = GetPath(loader,false,true)
              var MoveSettings = BrowserAutomationStudio_GetMoveJson(loader)
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({text:TypeData["updated"],move_settings: MoveSettings,interval:TypeInterval["updated"],path: path["path"],waiter: path["waiter"], disableemulation: Check}) + BrowserAutomationStudio_GetWaitCode()
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "set")
          {
            var Value = GetInputConstructorValue("Value",loader);


            if(Value["original"].length == 0)
            {
              Invalid("Set value is empty");
              return;
            }

            try{
              var path = GetPath(loader,false,true)
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({set:Value["updated"],path: path["path"],waiter: path["waiter"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "set_integer")
          {
            var Value = GetInputConstructorValue("Value",loader);


            if(Value["original"].length == 0)
            {
              Invalid("Set value is empty");
              return;
            }

            try{
              var path = GetPath(loader,false,true)
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({set:Value["updated"],path: path["path"],waiter: path["waiter"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "set_random")
          {

            try{
              var path = GetPath(loader,false,true)
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({path: path["path"],waiter: path["waiter"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }
          _MACRO_INSERT_SELECT_
          else if(State == "log")
          {
            var val = GetInputConstructorValue("LogText", loader)

            if(val["original"].length > 0)
            {
               try{
                var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({text:val["updated"]})
                code = Normalize(code,0)
                BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
              }catch(e)
              {}
            }else
            {
              Invalid("Log data is empty");
              return;
            }
          }else if(State == "clearlog")
          {

             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "timeout")
          {
            var val = GetInputConstructorValue("Value", loader)
            var type = this.$el.find("#Type").val();

            if(val["original"].length > 0)
            {
               try{
                var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({timeout:val["updated"], type: type})
                code = Normalize(code,0)
                BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
              }catch(e)
              {}
            }else
            {
              Invalid("Value empty");
              return;
            }
          }else if(State == "url")
          {
            var Variable = this.$el.find("#SaveUrl").val().toUpperCase();

            if(Variable.length > 0)
            {
               try{
                var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Variable})
                code = Normalize(code,0)
                BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
              }catch(e)
              {}
            }else
            {
              Invalid("Variable is empty");
              return;
            }
          }else if(State == "executefunction")
          {
            var FunctionName = $("#FunctionName").val();

            if(FunctionName.length > 0)
            {
               try{
                var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({name:FunctionName})
                code = Normalize(code,0)
                BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, 1, false);
              }catch(e)
              {}
            }else
            {
              Invalid("Function is empty");
              return;
            }
          }else if(State == "executefunctioninseveralthreads")
          {
            var FunctionName = $("#FunctionName").val();
            var ThreadNumber = GetInputConstructorValue("ThreadNumber", loader)
            var SuccessNumber = GetInputConstructorValue("SuccessNumber", loader)
            var FailNumber = GetInputConstructorValue("FailNumber", loader)


            if(FunctionName.length <= 0)
            {
              Invalid("Function is empty");
              return;
            }

             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({name:FunctionName, thread: ThreadNumber["updated"], success: SuccessNumber["updated"], fail: FailNumber["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, 1, false);
            }catch(e)
            {}
          
          }else if(State == "setvariable")
          {
            var VariableName = this.$el.find("#SetVariableName").val().toUpperCase();
            var VariableValue = GetInputConstructorValue("SetVariableValue", loader)


            if(VariableName.length == 0)
            {
              Invalid("Variable name is empty");
              return;
            }

            if(VariableValue["original"].length == 0)
            {
              Invalid("Variable value is empty");
              return;
            }
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable_name:"VAR_" + VariableName,variable_value:VariableValue["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "incvariable")
          {
            var VariableName = this.$el.find("#SetVariableName").val().toUpperCase();
            var VariableValue = GetInputConstructorValue("IncVariableValue", loader)


            if(VariableName.length == 0)
            {
              Invalid("Variable name is empty");
              return;
            }

            if(VariableValue["original"].length == 0)
            {
              Invalid("Variable value is empty");
              return;
            }
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable_name:"VAR_" + VariableName,variable_value:VariableValue["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "incglobalvariable")
          {
            var VariableName = this.$el.find("#SetVariableName").val().toUpperCase();
            var VariableValue = GetInputConstructorValue("IncVariableValue", loader)


            if(VariableName.length == 0)
            {
              Invalid("Variable name is empty");
              return;
            }

            if(VariableValue["original"].length == 0)
            {
              Invalid("Variable value is empty");
              return;
            }
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable_name:JSON.stringify(VariableName),variable_value:VariableValue["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "xml")
          {
            var Variable = this.$el.find("#SaveXml").val().toUpperCase();

            if(Variable.length > 0)
            {
               try{
                var path = GetPath(loader)
                var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Variable,path: path["path"],waiter: path["waiter"]})
                code = Normalize(code,0)
                BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
              }catch(e)
              {}
            }else
            {
              Invalid("Variable is empty");
              return;
            }
          }else if(State == "coordinates")
          {
            var X = this.$el.find("#X").val().toUpperCase();
            var Y = this.$el.find("#Y").val().toUpperCase();
            var Width = this.$el.find("#Width").val().toUpperCase();
            var Height = this.$el.find("#Height").val().toUpperCase();


            if(X.length == 0)
            {
              Invalid("X is empty");
              return;
            }

            if(Y.length == 0)
            {
              Invalid("Y is empty");
              return;
            }

            if(Width.length == 0)
            {
              Invalid("Width is empty");
              return;
            }

            if(Height.length == 0)
            {
              Invalid("Height is empty");
              return;
            }

            try{
              var path = GetPath(loader)
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({x:"VAR_" + X,y:"VAR_" + Y,width:"VAR_" + Width,height:"VAR_" + Height,path: path["path"],waiter: path["waiter"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
            
          }else if(State == "exist")
          {
            var Variable = this.$el.find("#Save").val().toUpperCase();
            var CheckIsvisible = $("#Check").is(':checked')

            if(Variable.length > 0)
            {
               try{
                var path = GetPath(loader)
                var imagesearch = false 
                if(typeof(path["imagesearch"]) != "undefined")
                {
                  imagesearch = path["imagesearch"]
                }
                var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Variable,path: path["path"],waiter: path["waiter"], imagesearch: imagesearch, isvisible: CheckIsvisible, query: path["query"]})
                code = Normalize(code,0)
                BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
              }catch(e)
              {}
            }else
            {
              Invalid("Variable is empty");
              return;
            }
          }else if(State == "clickelement")
          {
             var Check = $("#Check").is(':checked')

             try{
              var path = GetPath(loader,false,true)
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({path: path["path"],waiter: path["waiter"], disableemulation: Check}) + BrowserAutomationStudio_GetWaitCode()
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "check")
          {
             try{
              var path = GetPath(loader,false,true)
              var MoveSettings = BrowserAutomationStudio_GetMoveJson(loader)
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({move_settings: MoveSettings,path: path["path"],waiter: path["waiter"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "focus")
          {
             try{
              var path = GetPath(loader)
              var MoveSettings = BrowserAutomationStudio_GetMoveJson(loader)

              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({move_settings: MoveSettings,path: path["path"],waiter: path["waiter"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "moveelement")
          {
             try{
              var path = GetPath(loader,false,true)
              var MoveSettings = BrowserAutomationStudio_GetMoveJson(loader)

              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({move_settings: MoveSettings,path: path["path"],waiter: path["waiter"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }
          else if(State == "dragelement")
          {
             try{
              var path = GetPath(loader,false,true)
              var MoveSettings = BrowserAutomationStudio_GetMoveJson(loader)
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({move_settings: MoveSettings,path: path["path"],waiter: path["waiter"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }
          else if(State == "dropelement")
          {
             try{
              var path = GetPath(loader,false,true)
              var MoveSettings = BrowserAutomationStudio_GetMoveJson(loader)
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({move_settings: MoveSettings,path: path["path"],waiter: path["waiter"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "moveandclickelement")
          {
            var Check = $("#Check").is(':checked')

             try{
              var path = GetPath(loader,false,true)
              var MoveSettings = BrowserAutomationStudio_GetMoveJson(loader)
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({path: path["path"],waiter: path["waiter"], disableemulation: Check, move_settings: MoveSettings}) + BrowserAutomationStudio_GetWaitCode()
              code = Normalize(code,0)

              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "clear")
          {
             try{
              var path = GetPath(loader,false,true)
              var MoveSettings = BrowserAutomationStudio_GetMoveJson(loader)

              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({move_settings: MoveSettings,path: path["path"],waiter: path["waiter"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "script")
          {
            var Variable = this.$el.find("#SaveScript").val().toUpperCase();
            var Script = GetInputConstructorValue("ScriptValue", loader);
            if(Variable.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
            if(Script["original"].length == 0)
            {
              Invalid("Script is empty");
              return;
            }

             try{
              var path = GetPath(loader)
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Variable,path: path["path"],waiter: path["waiter"],script: Script["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "captcha")
          {
            var Variable = this.$el.find("#Save").val().toUpperCase();
            var Method = GetInputConstructorValue("Method", loader);
            var Antigate = GetInputConstructorValue("Antigate", loader);
            var Server = GetInputConstructorValue("Server", loader);
            if(Variable.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
            if(Method["original"].length == 0)
            {
              Invalid("Method is empty");
              return;
            }

             try{

              var path = GetPath(loader)
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Variable,path: path["path"],waiter: path["waiter"],method: Method["updated"], antigate: Antigate["updated"], serverurl: Server["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "screenshot")
          {
            var Variable = this.$el.find("#Save").val().toUpperCase();
            if(Variable.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
            
             try{

              var path = GetPath(loader)
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Variable,path: path["path"],waiter: path["waiter"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "attr")
          {

            var Save = this.$el.find("#Save").val().toUpperCase();
            var Value = GetInputConstructorValue("Value", loader);
            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
            if(Value["original"].length == 0)
            {
              Invalid("Attr is empty");
              return;
            }
             try{
              var path = GetPath(loader)
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save,path: path["path"],waiter: path["waiter"],attr: Value["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "length")
          {
            var Save = this.$el.find("#Save").val().toUpperCase();

            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
             try{
              var path = GetPath(loader,true)
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save,path: path["path"],waiter: path["waiter"], query: path["query"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "waitfiledownload")
          {
            var Save = this.$el.find("#Save").val().toUpperCase();

            if(Save.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
             try{
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Save})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "loopelement")
          {
             try{
              var path = GetPath(loader, true)

              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({path: path["path"],waiter: path["waiter"], querycss: path["querycss"], querymatch: path["querymatch"], queryxpath: path["queryxpath"]})

              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, 1, false);
            }catch(e)
            {}

          }else if(State == "set_attr")
          {
            var Name = GetInputConstructorValue("Name", loader);
            var Value = GetInputConstructorValue("Value", loader);

            if(Name["original"].length == 0)
            {
              Invalid("Name is empty");
              return;
            }
            if(Value["original"].length == 0)
            {
              Invalid("Value is empty");
              return;
            }
             try{
              var path = GetPath(loader)
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({path: path["path"],waiter: path["waiter"],value: Value["updated"],name: Name["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "style")
          {
            var Variable = this.$el.find("#Save").val().toUpperCase();
            var Value = GetInputConstructorValue("Value", loader);
            if(Variable.length == 0)
            {
              Invalid("Variable is empty");
              return;
            }
            if(Value["original"].length == 0)
            {
              Invalid("Style is empty");
              return;
            }

             try{
              var path = GetPath(loader)
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Variable,path: path["path"],waiter: path["waiter"],style: Value["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "text")
          {
            var Variable = this.$el.find("#SaveText").val().toUpperCase();

            if(Variable.length > 0)
            {
               try{
                var path = GetPath(loader)
                var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({variable:"VAR_" + Variable,path: path["path"],waiter: path["waiter"]})
                code = Normalize(code,0)
                BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
              }catch(e)
              {}
            }else
            {
              Invalid("Variable is empty");
              return;
            }
          }else if(State == "restrictpopups")
          {
             try{
              var path = GetPath(loader)
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "allowpopups")
          {
            try{
              var path = GetPath(loader)
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "restrictdownloads")
          {
             try{
              var path = GetPath(loader)
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "allowdownloads")
          {
            try{
              var path = GetPath(loader)
              var code = loader.GetAdditionalData() + _.template($('#' + State + "_code").html())({})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "click")
          {
            var MoveX = GetInputConstructorValue("ClickX", loader);
            var MoveY = GetInputConstructorValue("ClickY", loader);

            try{
              var code = loader.GetAdditionalData() +  _.template($('#' + State + "_code").html())({x:MoveX["updated"],y:MoveY["updated"]}) + BrowserAutomationStudio_GetWaitCode()
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "move")
          {
            var MoveX = GetInputConstructorValue("MoveX", loader);
            var MoveY = GetInputConstructorValue("MoveY", loader);

            try{
              var MoveSettings = BrowserAutomationStudio_GetMoveJson(loader)
              var code = loader.GetAdditionalData() +  _.template($('#' + State + "_code").html())({move_settings: MoveSettings,x:MoveX["updated"],y:MoveY["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "drag")
          {
            var MoveX = GetInputConstructorValue("X", loader);
            var MoveY = GetInputConstructorValue("Y", loader);

            try{
              var MoveSettings = BrowserAutomationStudio_GetMoveJson(loader)
              var code = loader.GetAdditionalData() +  _.template($('#' + State + "_code").html())({move_settings: MoveSettings,x:MoveX["updated"],y:MoveY["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "drop")
          {
            var MoveX = GetInputConstructorValue("X", loader);
            var MoveY = GetInputConstructorValue("Y", loader);

            try{
              var MoveSettings = BrowserAutomationStudio_GetMoveJson(loader)
              var code = loader.GetAdditionalData() +  _.template($('#' + State + "_code").html())({move_settings: MoveSettings,x:MoveX["updated"],y:MoveY["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }
          else if(State == "mousesettings")
          {
            var Speed = GetInputConstructorValue("Speed", loader);
            var Gravity = GetInputConstructorValue("Gravity", loader);
            var Deviation = GetInputConstructorValue("Deviation", loader);

            try{
              var code = loader.GetAdditionalData() +  _.template($('#' + State + "_code").html())({speed:Speed["updated"],gravity:Gravity["updated"],deviation:Deviation["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }
          else if(State == "browsersettings")
          {
            var IsSafe = GetInputConstructorValue("IsSafe", loader);
            var UseFlash = GetInputConstructorValue("UseFlash", loader);
            var SkipFrames = GetInputConstructorValue("SkipFrames", loader);
            var RefreshConnections = GetInputConstructorValue("RefreshConnections", loader);
            var EncodeUtf8 = GetInputConstructorValue("EncodeUtf8", loader);
            

            try{
              var code = loader.GetAdditionalData() +  _.template($('#' + State + "_code").html())({IsSafe:IsSafe["updated"],UseFlash:UseFlash["updated"],SkipFrames:SkipFrames["updated"],RefreshConnections:RefreshConnections["updated"],EncodeUtf8:EncodeUtf8["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }
          else if(State == "scroll")
          {
            var X = GetInputConstructorValue("X", loader);
            var Y = GetInputConstructorValue("Y", loader);

            try{
              var code = loader.GetAdditionalData() +  _.template($('#' + State + "_code").html())({x:X["updated"],y:Y["updated"]}) + BrowserAutomationStudio_GetWaitCode()
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "renderscreen")
          {
            var X = GetInputConstructorValue("X", loader);
            var Y = GetInputConstructorValue("Y", loader);
            var Width = GetInputConstructorValue("Width", loader);
            var Height = GetInputConstructorValue("Height", loader);
            var Variable = this.$el.find("#Save").val().toUpperCase();
            try{
              var code = loader.GetAdditionalData() +  _.template($('#' + State + "_code").html())({variable:"VAR_" + Variable, x:X["updated"],y:Y["updated"],width:Width["updated"],height:Height["updated"]})

              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}

          }else if(State == "moveandclick")
          {
            var MoveX = GetInputConstructorValue("X", loader);
            var MoveY = GetInputConstructorValue("Y", loader);

            try{
              var MoveSettings = BrowserAutomationStudio_GetMoveJson(loader)
              var code = loader.GetAdditionalData() +  _.template($('#' + State + "_code").html())({move_settings: MoveSettings,x:MoveX["updated"],y:MoveY["updated"]}) + BrowserAutomationStudio_GetWaitCode()
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "addtab")
          {
            var Url = GetInputConstructorValue("Url", loader);
            if(Url["original"].length == 0)
            {
              Invalid("Url is empty");
              return;
            }
            try{
              var code = loader.GetAdditionalData() +  _.template($('#' + State + "_code").html())({url:Url["updated"]}) + BrowserAutomationStudio_GetWaitCode()
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "selecttab")
          {
            var Index = GetInputConstructorValue("Index", loader);
            if(Index["original"].length == 0)
            {
              Invalid("Index is empty");
              return;
            }
            try{
              var code = loader.GetAdditionalData() +  _.template($('#' + State + "_code").html())({index:Index["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "closetab")
          {
            var Index = GetInputConstructorValue("Index", loader);
            if(Index["original"].length == 0)
            {
              Invalid("Index is empty");
              return;
            }
            try{
              var code = loader.GetAdditionalData() +  _.template($('#' + State + "_code").html())({index:Index["updated"]})
              code = Normalize(code,0)
              BrowserAutomationStudio_Append("", BrowserAutomationStudio_SaveControls() + code, action, DisableIfAdd);
            }catch(e)
            {}
          }else if(State == "threadnumber")
          {
            var ThreadNumber = GetInputConstructorValue("ThreadNumber", loader)["original"];
            if(ThreadNumber.toString().length == 0)
              ThreadNumber = "1"
            try{BrowserAutomationStudio_Append("_threadnumber_", ThreadNumber, action);}catch(e){}
          }else if(State == "successnumber")
          {
            var SuccessNumber = GetInputConstructorValue("SuccessNumber", loader)["original"];
            if(SuccessNumber.toString().length == 0)
              SuccessNumber = "1"
            try{BrowserAutomationStudio_Append("_successnumber_", SuccessNumber.toString(), action);}catch(e){}
          }else if(State == "failnumber")
          {
            var FailNumber = GetInputConstructorValue("FailNumber", loader)["original"];
            if(FailNumber.toString().length == 0)
              FailNumber = "1"
            try{BrowserAutomationStudio_Append("_failnumber_", FailNumber.toString(), action);}catch(e){}
          }

          _Router.navigate("", true);
      },

      initialize: function(){
        this.templates =
        {
          "main" : _.template($('#main').html()),
          "load" : _.template($('#load').html()),
          "type" : _.template($('#type').html()),
          "waitload" : _.template($('#waitload').html()),
          "waiturl" : _.template($('#waiturl').html()),
          "waitfullload" : _.template($('#waitfullload').html()),
          "waitcontent" : _.template($('#waitcontent').html()),
          "waitcss" : _.template($('#waitcss').html()),
          "sleep" : _.template($('#sleep').html()),
          "resize" : _.template($('#resize').html()),
          "proxy" : _.template($('#proxy').html()),
          "click" : _.template($('#click').html()),
          "move" : _.template($('#move').html()),
          "moveandclick" : _.template($('#moveandclick').html()),
          "threadnumber" : _.template($('#threadnumber').html()),
          "failnumber" : _.template($('#failnumber').html()),
          "successnumber" : _.template($('#successnumber').html()),
          "log" : _.template($('#log').html()),
          "clearlog" : _.template($('#clearlog').html()),
          "url" : _.template($('#url').html()),
          "xml" : _.template($('#xml').html()),
          "coordinates" : _.template($('#coordinates').html()),
          "text" : _.template($('#text').html()),
          "setvariable": _.template($('#setvariable').html()),
          "if": _.template($('#if').html()),
          "while": _.template($('#while').html()),
          "for": _.template($('#for').html()),
          "foreach": _.template($('#foreach').html()),
          "executefunction": _.template($('#executefunction').html()),
          "break": _.template($('#break').html()),
          "continue": _.template($('#continue').html()),
          "fail": _.template($('#fail').html()),
          "success": _.template($('#success').html()),
          "custom": _.template($('#custom').html()),
          "script": _.template($('#script').html()),
          "clickelement": _.template($('#clickelement').html()),
          "moveelement": _.template($('#moveelement').html()),
          "moveandclickelement": _.template($('#moveandclickelement').html()),
          "clear": _.template($('#clear').html()),
          "typeelement": _.template($('#typeelement').html()),
          "exist": _.template($('#exist').html()),
          "style": _.template($('#style').html()),
          "check": _.template($('#check').html()),
          "focus": _.template($('#focus').html()),
          "set": _.template($('#set').html()),
          "set_integer": _.template($('#set_integer').html()),
          "set_random": _.template($('#set_random').html()),
          "attr": _.template($('#attr').html()),
          "set_attr": _.template($('#set_attr').html()),
          "captcha": _.template($('#captcha').html()),
          "screenshot": _.template($('#screenshot').html()),
          "length": _.template($('#length').html()),
          "loopelement": _.template($('#loopelement').html()),
          "setheader": _.template($('#setheader').html()),
          "solvecaptcha": _.template($('#solvecaptcha').html()),
          "javascript": _.template($('#javascript').html()),
          "reset": _.template($('#reset').html()),
          "openfile": _.template($('#openfile').html()),
          "getcookiesforurl": _.template($('#getcookiesforurl').html()),
          "savecookies": _.template($('#savecookies').html()),
          "restorecookies": _.template($('#restorecookies').html()),
          "scroll": _.template($('#scroll').html()),
          "html": _.template($('#html').html()),
          "renderscreen": _.template($('#renderscreen').html()),
          "cachemaskallow": _.template($('#cachemaskallow').html()),
          "cachemaskdeny": _.template($('#cachemaskdeny').html()),
          "cachemaskclear": _.template($('#cachemaskclear').html()),
          "requestmaskallow": _.template($('#requestmaskallow').html()),
          "requestmaskdeny": _.template($('#requestmaskdeny').html()),
          "requestmaskclear": _.template($('#requestmaskclear').html()),
          "cleardata": _.template($('#cleardata').html()),
          "clearmasks": _.template($('#clearmasks').html()),
          "getstatus": _.template($('#getstatus').html()),
          "isloaded": _.template($('#isloaded').html()),
          "getfromcache": _.template($('#getfromcache').html()),
          "result": _.template($('#result').html()),
          "base64": _.template($('#base64').html()),
          "globalset": _.template($('#globalset').html()),
          "globalget": _.template($('#globalget').html()),
          "emailsettings": _.template($('#emailsettings').html()),
          "emailproxy": _.template($('#emailproxy').html()),
          "emaillength": _.template($('#emaillength').html()),
          "emailsearchfirst": _.template($('#emailsearchfirst').html()),
          "emailsearchall": _.template($('#emailsearchall').html()),
          "emailpull": _.template($('#emailpull').html()),
          "httpclientproxy": _.template($('#httpclientproxy').html()),
          "httpclientreset": _.template($('#httpclientreset').html()),
          "httpclientdownload": _.template($('#httpclientdownload').html()),
          "httpclientget": _.template($('#httpclientget').html()),
          "httpclientpost": _.template($('#httpclientpost').html()),
          "httpclienturl": _.template($('#httpclienturl').html()),
          "httpclientcontent": _.template($('#httpclientcontent').html()),
          "httpclientstatus": _.template($('#httpclientstatus').html()),
          "httpclientgetheader": _.template($('#httpclientgetheader').html()),
          "httpclientsetheader": _.template($('#httpclientsetheader').html()),
          "httpclientclearheader": _.template($('#httpclientclearheader').html()),
          "httpclientgetcookiesforurl": _.template($('#httpclientgetcookiesforurl').html()),
          "httpclientsavecookies": _.template($('#httpclientsavecookies').html()),
          "httpclientrestorecookies": _.template($('#httpclientrestorecookies').html()),
          "httpclientfailonerror": _.template($('#httpclientfailonerror').html()),
          "httpclientiserror": _.template($('#httpclientiserror').html()),
          "httpclientgeterrorstring": _.template($('#httpclientgeterrorstring').html()),
          "httpclientxpathxml": _.template($('#httpclientxpathxml').html()),
          "httpclientxpathxmllist": _.template($('#httpclientxpathxmllist').html()),
          "httpclientxpathtext": _.template($('#httpclientxpathtext').html()),
          "httpclientxpathtextlist": _.template($('#httpclientxpathtextlist').html()),
          "httpclientxpathcount": _.template($('#httpclientxpathcount').html()),
          "httpclientxpathexists": _.template($('#httpclientxpathexists').html()),
          "parseline": _.template($('#parseline').html()),
          "waitelement": _.template($('#waitelement').html()),
          "timeout": _.template($('#timeout').html()),
          "promptresult": _.template($('#promptresult').html()),
          "httpauth": _.template($('#httpauth').html()),
          "solverfailed": _.template($('#solverfailed').html()),
          "onloadjavascript": _.template($('#onloadjavascript').html()),
          "incvariable": _.template($('#incvariable').html()),
          "incglobalvariable": _.template($('#incglobalvariable').html()),
          "ignoreerrors": _.template($('#ignoreerrors').html()),
          "die": _.template($('#die').html()),
          "template": _.template($('#template').html()),
          "replacestring": _.template($('#replacestring').html()),
          "randomint": _.template($('#randomint').html()),
          "randomstring": _.template($('#randomstring').html()),
          "addtab": _.template($('#addtab').html()),
          "selecttab": _.template($('#selecttab').html()),
          "closetab": _.template($('#closetab').html()),
          "drag": _.template($('#drag').html()),
          "drop": _.template($('#drop').html()),
          "dragelement": _.template($('#dragelement').html()),
          "dropelement": _.template($('#dropelement').html()),
          "waitfiledownload": _.template($('#waitfiledownload').html()),
          "loadcookiesfrombrowser": _.template($('#loadcookiesfrombrowser').html()),
          "loadcookiesfromhttpclient": _.template($('#loadcookiesfromhttpclient').html()),
          "closebrowser": _.template($('#closebrowser').html()),
          "openbrowser": _.template($('#openbrowser').html()),
          "goto": _.template($('#goto').html()),
          "label": _.template($('#label').html()),
          "restrictpopups": _.template($('#restrictpopups').html()),
          "allowpopups": _.template($('#allowpopups').html()),
          "restrictdownloads": _.template($('#restrictdownloads').html()),
          "allowdownloads": _.template($('#allowdownloads').html()),
          "mousesettings": _.template($('#mousesettings').html()),
          "browsersettings": _.template($('#browsersettings').html()),
          "executefunctioninseveralthreads": _.template($('#executefunctioninseveralthreads').html())
          _MACRO_INSERT_TEMPLATES_
        }
        this.model.bind('change', this.render, this);

        try{
          BrowserAutomationStudio_Initialized();
        }catch(e)
        {}
        this.render();
      },

      render: function(){
        _PreserveMainPosition.BeforUrlChanged(this.model.get("state"))
        var d = this.collection.toJSON();
        if(_Schema && _Schema.length == 0)
        {
          d = d.filter(function(el){
            return !el["show_only_with_database"]
          })
        }

        $("#containerdata").html(this.templates[this.model.get("state")]({data:d,model:this.model.toJSON(),selector:_SelectorModel.toJSON()}))
        _Filter.InstallEvents()
        $(".variable-input, .function-input").keypress(function(e){
          var charCode = !e.charCode ? e.which : e.charCode;
          var IsGoodchar =  (charCode == ','.charCodeAt(0) && $(e.target).is("[data-append-array]")) || charCode >= 'A'.charCodeAt(0) && charCode <= 'Z'.charCodeAt(0) || charCode >= 'a'.charCodeAt(0) && charCode <= 'z'.charCodeAt(0) || charCode == '_'.charCodeAt(0) || charCode >= '0'.charCodeAt(0) && charCode <= '9'.charCodeAt(0)
          if(!IsGoodchar)
              e.preventDefault();
        })
        tr()
        this.updatepath()
        
        $(".actions").css("height", window.innerHeight * (100.0 / _Z) - 40 + "px")
        $(".leftactionpanel").css("height", window.innerHeight * (100.0 / _Z) - 45 + "px")
        $(".leftactionpaneltitlebody").css("min-height", window.innerHeight * (100.0 / _Z) - 95 + "px")
        $(".actions").css("overflow-y","auto")
        $(".leftactionpanel").css("overflow-y","auto")
        $(".leftactionpanel").css("overflow-x","hidden")
        

        $('[data-toggle="tooltip"]').tooltip({trigger:'hover', template:'<div class="mytooltip" role="tooltip"><div class="mytooltip-arrow tooltip-arrow"></div><div class="mytooltip-inner tooltip-inner"></div></div>',delay: { "show": 500, "hide": 100 }})

        _PreserveMainPosition.AfterUrlChanged(this.model.get("state"))

        if(CurrentTab == "history")
        {
          BrowserAutomationStudio_RenderHistory();
        }else if (CurrentTab == "bookmarks")
        {
          BrowserAutomationStudio_RenderBookmarks();
        }

        BrowserAutomationStudio_InstallBookmarks();

        BrowserAutomationStudio_InitSearch();

        BrowserAutomationStudio_TestPathInternal();

        BrowserAutomationStudio_SetExecuteType();

        $("body").show()

      },

      /*showtooltip: function(e)
      {
        var name = $(e.target).attr("data-name")
        var description = $(e.target).attr("data-description")
        if(typeof(name) != "undefined" && typeof(description) != "undefined")
        {
          $("#tooltip").html("<strong>" + name + "</strong> : " + description)
        }
      },*/


    });

    var Router = Backbone.Router.extend({
        routes: {
            "": "main",
            "!/": "main",
            "!/ok": "ok",
            "!/load": "load",
            "!/timeout": "timeout",
            "!/type": "type",
            "!/waitload": "waitload",
            "!/waitfullload": "waitfullload",
            "!/waiturl": "waiturl",
            "!/waitcontent": "waitcontent",
            "!/waitcss": "waitcss",
            "!/sleep": "sleep",
            "!/resize": "resize",
            "!/proxy": "proxy",
            "!/move": "move",
            "!/click": "click",
            "!/moveandclick": "moveandclick",
            "!/threadnumber": "threadnumber",
            "!/successnumber": "successnumber",
            "!/failnumber": "failnumber",
            "!/log": "log",
            "!/clearlog": "clearlog",
            "!/url": "url",
            "!/xml": "xml",
            "!/coordinates": "coordinates",
            "!/text": "text",
            "!/setvariable": "setvariable",
            "!/if": "if",
            "!/while": "while",
            "!/for": "for",
            "!/foreach": "foreach",
            "!/executefunction": "executefunction",
            "!/break": "break",
            "!/continue": "continue",
            "!/fail": "fail",
            "!/success": "success",
            "!/custom": "custom",
            "!/script": "script",
            "!/clickelement": "clickelement",
            "!/moveelement": "moveelement",
            "!/moveandclickelement": "moveandclickelement",
            "!/clear": "clear",
            "!/typeelement": "typeelement",
            "!/exist": "exist",
            "!/style": "style",
            "!/check": "check",
            "!/focus": "focus",
            "!/set": "set",
            "!/set_integer": "set_integer",
            "!/set_random": "set_random",
            "!/attr": "attr",
            "!/set_attr": "set_attr",
            "!/captcha": "captcha",
            "!/screenshot": "screenshot",
            "!/length": "length",
            "!/loopelement": "loopelement",
            "!/setheader": "setheader",
            "!/solvecaptcha": "solvecaptcha",
            "!/javascript": "javascript",
            "!/reset": "reset",
            "!/openfile": "openfile",
            "!/getcookiesforurl": "getcookiesforurl",
            "!/savecookies": "savecookies",
            "!/restorecookies": "restorecookies",
            "!/scroll": "scroll",
            "!/html": "html",
            "!/renderscreen": "renderscreen",
            "!/cachemaskallow": "cachemaskallow",
            "!/cachemaskdeny": "cachemaskdeny",
            "!/cachemaskclear": "cachemaskclear",
            "!/requestmaskallow": "requestmaskallow",
            "!/requestmaskdeny": "requestmaskdeny",
            "!/requestmaskclear": "requestmaskclear",
            "!/cleardata": "cleardata",
            "!/clearmasks": "clearmasks",
            "!/getstatus": "getstatus",
            "!/isloaded": "isloaded",
            "!/getfromcache": "getfromcache",
            "!/result": "result",
            "!/base64": "base64",
            "!/globalset": "globalset",
            "!/globalget": "globalget",
            "!/emailsettings": "emailsettings",
            "!/emailproxy": "emailproxy",
            "!/emaillength": "emaillength",
            "!/emailsearchfirst": "emailsearchfirst",
            "!/emailsearchall": "emailsearchall",
            "!/emailpull": "emailpull",
            "!/httpclientproxy": "httpclientproxy",
            "!/httpclientreset": "httpclientreset",
            "!/httpclientdownload": "httpclientdownload",
            "!/httpclientget": "httpclientget",
            "!/httpclientpost": "httpclientpost",
            "!/httpclienturl": "httpclienturl",
            "!/httpclientcontent": "httpclientcontent",
            "!/httpclientstatus": "httpclientstatus",
            "!/httpclientgetheader": "httpclientgetheader",
            "!/httpclientsetheader": "httpclientsetheader",
            "!/httpclientclearheader": "httpclientclearheader",
            "!/httpclientgetcookiesforurl": "httpclientgetcookiesforurl",
            "!/httpclientsavecookies": "httpclientsavecookies",
            "!/httpclientrestorecookies": "httpclientrestorecookies",
            "!/httpclientfailonerror": "httpclientfailonerror",
            "!/httpclientiserror": "httpclientiserror",
            "!/httpclientgeterrorstring": "httpclientgeterrorstring",
            "!/httpclientxpathxml": "httpclientxpathxml",
            "!/httpclientxpathxmllist": "httpclientxpathxmllist",
            "!/httpclientxpathtext": "httpclientxpathtext",
            "!/httpclientxpathtextlist": "httpclientxpathtextlist",
            "!/httpclientxpathcount": "httpclientxpathcount",
            "!/httpclientxpathexists": "httpclientxpathexists",
            "!/parseline": "parseline",
            "!/waitelement": "waitelement",
            "!/promptresult": "promptresult",
            "!/httpauth": "httpauth",
            "!/solverfailed": "solverfailed",
            "!/onloadjavascript": "onloadjavascript",
            "!/incvariable": "incvariable",
            "!/incglobalvariable": "incglobalvariable",
            "!/ignoreerrors": "ignoreerrors",
            "!/die": "die",
            "!/template": "template",
            "!/replacestring": "replacestring",
            "!/randomstring": "randomstring",
            "!/addtab": "addtab",
            "!/selecttab": "selecttab",
            "!/closetab": "closetab",
            "!/randomint": "randomint",
            "!/drag": "drag",
            "!/drop": "drop",
            "!/dragelement": "dragelement",
            "!/dropelement": "dropelement",
            "!/waitfiledownload": "waitfiledownload",
            "!/loadcookiesfrombrowser": "loadcookiesfrombrowser",
            "!/loadcookiesfromhttpclient": "loadcookiesfromhttpclient",
            "!/closebrowser": "closebrowser",
            "!/openbrowser": "openbrowser",
            "!/label": "label",
            "!/goto": "goto",
            "!/restrictpopups": "restrictpopups",
            "!/allowpopups": "allowpopups",
            "!/restrictdownloads": "restrictdownloads",
            "!/allowdownloads": "allowdownloads",
            "!/mousesettings": "mousesettings",
            "!/browsersettings": "browsersettings",
            "!/executefunctioninseveralthreads": "executefunctioninseveralthreads"
            _MACRO_INSERT_ROUTER_DEF_
        },

        main: function () {
          CurrentGroup = ""
          _GobalModel.set({ state: "main" });
          
        },
        timeout: function () {
          _GobalModel.set({ state: "timeout" });
        },
        load: function () {
          _GobalModel.set({ state: "load" });
        },
        type: function () {
          _GobalModel.set({ state: "type" });
        },
        waitload: function () {
          _GobalModel.set({ state: "waitload" });
        },
        waitfullload: function () {
          _GobalModel.set({ state: "waitfullload" });
        },
        waiturl: function () {
          _GobalModel.set({ state: "waiturl" });
        },
        waitcontent: function () {
          _GobalModel.set({ state: "waitcontent" });
        },
        waitcss: function () {
          _GobalModel.set({ state: "waitcss" });
        },
        sleep: function () {
          _GobalModel.set({ state: "sleep" });
        },
        resize: function () {
          _GobalModel.set({ state: "resize" });
        },
        proxy: function () {
          _GobalModel.set({ state: "proxy" });
        },
        move: function () {
          _GobalModel.set({ state: "move" });
        },
        click: function () {
          _GobalModel.set({ state: "click" });
        },
        moveandclick: function () {
          _GobalModel.set({ state: "moveandclick" });
        },
        threadnumber: function () {
          _GobalModel.set({ state: "threadnumber" });
        },
        successnumber: function () {
          _GobalModel.set({ state: "successnumber" });
        },
        failnumber: function () {
          _GobalModel.set({ state: "failnumber" });
        },
        log: function () {
          _GobalModel.set({ state: "log" });
        },
        clearlog: function () {
          _GobalModel.set({ state: "clearlog" });
        },
        url: function () {
          _GobalModel.set({ state: "url" });
        },
        xml: function () {
          _GobalModel.set({ state: "xml" });
        },
        coordinates: function () {
          _GobalModel.set({ state: "coordinates" });
        },
        text: function () {
          _GobalModel.set({ state: "text" });
        },
        setvariable: function () {
          _GobalModel.set({ state: "setvariable" });
        },
        if: function () {
          _GobalModel.set({ state: "if" });
        },
        while: function () {
          _GobalModel.set({ state: "while" });
        },
        for: function () {
          _GobalModel.set({ state: "for" });
        },
        foreach: function () {
          _GobalModel.set({ state: "foreach" });
        },
        executefunction: function(){
          _GobalModel.set({ state: "executefunction" });
        },
        break: function(){
          _GobalModel.set({ state: "break" });
        },
        continue: function(){
          _GobalModel.set({ state: "continue" });
        },
        success: function(){
          _GobalModel.set({ state: "success" });
        },
        fail: function(){
          _GobalModel.set({ state: "fail" });
        },
        custom: function(){
          _GobalModel.set({ state: "custom" });
        },
        script: function(){
          _GobalModel.set({ state: "script" });
        },
        clickelement: function(){
          _GobalModel.set({ state: "clickelement" });
        },
        moveelement: function(){
          _GobalModel.set({ state: "moveelement" });
        },
        moveandclickelement: function(){
          _GobalModel.set({ state: "moveandclickelement" });
        },
        clear: function(){
          _GobalModel.set({ state: "clear" });
        },
        typeelement: function(){
          _GobalModel.set({ state: "typeelement" });
        },
        exist: function(){
          _GobalModel.set({ state: "exist" });
        },
        style: function(){
          _GobalModel.set({ state: "style" });
        },
        check: function(){
          _GobalModel.set({ state: "check" });
        },
        focus: function(){
          _GobalModel.set({ state: "focus" });
        },
        set: function(){
          _GobalModel.set({ state: "set" });
        },
        set_integer: function(){
          _GobalModel.set({ state: "set_integer" });
        },
        set_random: function(){
          _GobalModel.set({ state: "set_random" });
        },
        attr: function(){
          _GobalModel.set({ state: "attr" });
        },
        set_attr: function(){
          _GobalModel.set({ state: "set_attr" });
        },
        captcha: function(){
          _GobalModel.set({ state: "captcha" });
        },
        screenshot: function(){
          _GobalModel.set({ state: "screenshot" });
        },
        length: function(){
          _GobalModel.set({ state: "length" });
        },
        loopelement: function(){
          _GobalModel.set({ state: "loopelement" });
        },
        setheader: function(){
          _GobalModel.set({ state: "setheader" });
        },
        solvecaptcha: function(){
                  _GobalModel.set({ state: "solvecaptcha" });
                },
        javascript: function(){
                  _GobalModel.set({ state: "javascript" });
                },
        reset: function(){
                  _GobalModel.set({ state: "reset" });
                },
        openfile: function(){
                  _GobalModel.set({ state: "openfile" });
                },
        getcookiesforurl: function(){
                  _GobalModel.set({ state: "getcookiesforurl" });
                },
        savecookies: function(){
                  _GobalModel.set({ state: "savecookies" });
                },
        restorecookies: function(){
                  _GobalModel.set({ state: "restorecookies" });
                },
        scroll: function(){
                  _GobalModel.set({ state: "scroll" });
                },
        html: function(){
                  _GobalModel.set({ state: "html" });
                },
        renderscreen: function(){
                  _GobalModel.set({ state: "renderscreen" });
                },
        cachemaskallow: function(){
                  _GobalModel.set({ state: "cachemaskallow" });
                },
        cachemaskdeny: function(){
                  _GobalModel.set({ state: "cachemaskdeny" });
                },
        cachemaskclear: function(){
                  _GobalModel.set({ state: "cachemaskclear" });
                },
        requestmaskallow: function(){
                  _GobalModel.set({ state: "requestmaskallow" });
                },
        requestmaskdeny: function(){
                  _GobalModel.set({ state: "requestmaskdeny" });
                },
        requestmaskclear: function(){
                  _GobalModel.set({ state: "requestmaskclear" });
                },
        cleardata: function(){
                  _GobalModel.set({ state: "cleardata" });
                },
        clearmasks: function(){
                  _GobalModel.set({ state: "clearmasks" });
                },
        getstatus: function(){
                  _GobalModel.set({ state: "getstatus" });
                },
        isloaded: function(){
                  _GobalModel.set({ state: "isloaded" });
                },
        getfromcache: function(){
                  _GobalModel.set({ state: "getfromcache" });
                },
        result: function(){
                  _GobalModel.set({ state: "result" });
                },
        base64: function(){
                  _GobalModel.set({ state: "base64" });
                },
        globalset: function(){
                  _GobalModel.set({ state: "globalset" });
                },
        globalget: function(){
                  _GobalModel.set({ state: "globalget" });
                },
        emailsettings: function(){
                  _GobalModel.set({ state: "emailsettings" });
                },
        emailproxy: function(){
                  _GobalModel.set({ state: "emailproxy" });
                },
        emaillength: function(){
                  _GobalModel.set({ state: "emaillength" });
                },
        emailsearchfirst: function(){
                  _GobalModel.set({ state: "emailsearchfirst" });
                },
        emailsearchall: function(){
                  _GobalModel.set({ state: "emailsearchall" });
                },
        emailpull: function(){
                  _GobalModel.set({ state: "emailpull" });
                },
        httpclientproxy: function(){
                  _GobalModel.set({ state: "httpclientproxy" });
                },
        httpclientreset: function(){
                  _GobalModel.set({ state: "httpclientreset" });
                },
        httpclientdownload: function(){
                  _GobalModel.set({ state: "httpclientdownload" });
                },
        httpclientget: function(){
                  _GobalModel.set({ state: "httpclientget" });
                },
        httpclientpost: function(){
                  _GobalModel.set({ state: "httpclientpost" });
                },
        httpclienturl: function(){
                  _GobalModel.set({ state: "httpclienturl" });
                },
        httpclientcontent: function(){
                  _GobalModel.set({ state: "httpclientcontent" });
                },
        httpclientstatus: function(){
                  _GobalModel.set({ state: "httpclientstatus" });
                },
        httpclientgetheader: function(){
                  _GobalModel.set({ state: "httpclientgetheader" });
                },
        httpclientsetheader: function(){
                  _GobalModel.set({ state: "httpclientsetheader" });
                },
        httpclientclearheader: function(){
                  _GobalModel.set({ state: "httpclientclearheader" });
                },
        httpclientgetcookiesforurl: function(){
                  _GobalModel.set({ state: "httpclientgetcookiesforurl" });
                },
        httpclientsavecookies: function(){
                  _GobalModel.set({ state: "httpclientsavecookies" });
                },
        httpclientrestorecookies: function(){
                  _GobalModel.set({ state: "httpclientrestorecookies" });
                },
        httpclientfailonerror: function(){
                  _GobalModel.set({ state: "httpclientfailonerror" });
                },
        httpclientiserror: function(){
                  _GobalModel.set({ state: "httpclientiserror" });
                },
        httpclientgeterrorstring: function(){
                  _GobalModel.set({ state: "httpclientgeterrorstring" });
                },
        httpclientxpathxml: function(){
                  _GobalModel.set({ state: "httpclientxpathxml" });
                },
        httpclientxpathxmllist: function(){
                  _GobalModel.set({ state: "httpclientxpathxmllist" });
                },
        httpclientxpathtext: function(){
                  _GobalModel.set({ state: "httpclientxpathtext" });
                },
        httpclientxpathtextlist: function(){
                  _GobalModel.set({ state: "httpclientxpathtextlist" });
                },
        httpclientxpathcount: function(){
                  _GobalModel.set({ state: "httpclientxpathcount" });
                },
        httpclientxpathexists: function(){
                  _GobalModel.set({ state: "httpclientxpathexists" });
                },
        parseline: function(){
                  _GobalModel.set({ state: "parseline" });
                },
        waitelement: function(){
                  _GobalModel.set({ state: "waitelement" });
                },
        promptresult: function(){
                  _GobalModel.set({ state: "promptresult" });
                },
        httpauth: function(){
                  _GobalModel.set({ state: "httpauth" });
                },
        solverfailed: function(){
          _GobalModel.set({ state: "solverfailed" });
        },
        onloadjavascript: function(){
          _GobalModel.set({ state: "onloadjavascript" });
        },
        incvariable: function(){
          _GobalModel.set({ state: "incvariable" });
        },
        incglobalvariable: function(){
          _GobalModel.set({ state: "incglobalvariable" });
        },
        ignoreerrors: function(){
          _GobalModel.set({ state: "ignoreerrors" });
        },
        die: function(){
          _GobalModel.set({ state: "die" });
        },
        template: function(){
          _GobalModel.set({ state: "template" });
        },
        replacestring: function(){
          _GobalModel.set({ state: "replacestring" });
        },
        randomstring: function(){
          _GobalModel.set({ state: "randomstring" });
        }
        ,
        randomint: function(){
          _GobalModel.set({ state: "randomint" });
        }
        ,
        addtab: function(){
          _GobalModel.set({ state: "addtab" });
        }
        ,
        selecttab: function(){
          _GobalModel.set({ state: "selecttab" });
        }
        ,closetab: function(){
          _GobalModel.set({ state: "closetab" });
        }
        ,drag: function(){
          _GobalModel.set({ state: "drag" });
        }
        ,drop: function(){
          _GobalModel.set({ state: "drop" });
        }
        ,dragelement: function(){
          _GobalModel.set({ state: "dragelement" });
        }
        ,dropelement: function(){
          _GobalModel.set({ state: "dropelement" });
        },
        waitfiledownload: function(){
          _GobalModel.set({ state: "waitfiledownload" });
        },
        loadcookiesfrombrowser: function(){
          _GobalModel.set({ state: "loadcookiesfrombrowser" });
        },
        loadcookiesfromhttpclient: function(){
          _GobalModel.set({ state: "loadcookiesfromhttpclient" });
        },openbrowser: function(){
          _GobalModel.set({ state: "openbrowser" });
        }
        ,closebrowser: function(){
          _GobalModel.set({ state: "closebrowser" });
        }
        ,label: function(){
          _GobalModel.set({ state: "label" });
        }
        ,goto: function(){
          _GobalModel.set({ state: "goto" });
        }
        ,restrictpopups: function(){
          _GobalModel.set({ state: "restrictpopups" });
        }
        ,allowpopups: function(){
          _GobalModel.set({ state: "allowpopups" });
        }
        ,restrictdownloads: function(){
          _GobalModel.set({ state: "restrictdownloads" });
        }
        ,allowdownloads: function(){
          _GobalModel.set({ state: "allowdownloads" });
        }
        ,mousesettings: function(){
          _GobalModel.set({ state: "mousesettings" });
        }
        ,browsersettings: function(){
          _GobalModel.set({ state: "browsersettings" });
        },
        executefunctioninseveralthreads: function(){
          _GobalModel.set({ state: "executefunctioninseveralthreads" });
        }
        _MACRO_INSERT_ROUTER_FUNC_
    });

    var _Router = new Router();



    var _TaskCollection = new TaskCollection([
                { description: tr("Browser"), type: "group", name: "browser", icon: _G["browser"]["icon"], info: tr(_G["browser"]["info"])},
                { name: tr(_A["load"]["name"]), description: tr(_A["load"]["description"]), ref: "load" },
                { name: tr(_A["url"]["name"]), description: tr(_A["url"]["description"]), ref: "url" },
                { name: tr(_A["html"]["name"]), description: tr(_A["html"]["description"]), ref: "html" },
                { name: tr(_A["type"]["name"]), description: tr(_A["type"]["description"]), ref: "type" },
                { name: tr(_A["resize"]["name"]), description: tr(_A["resize"]["description"]), ref: "resize" },
                { name: tr(_A["proxy"]["name"]), description: tr(_A["proxy"]["description"]), ref: "proxy" },
                { name: tr(_A["javascript"]["name"]), description: tr(_A["javascript"]["description"]), ref: "javascript" },
                { name: tr(_A["onloadjavascript"]["name"]), description: tr(_A["onloadjavascript"]["description"]), ref: "onloadjavascript" },
                { name: tr(_A["reset"]["name"]), description: tr(_A["reset"]["description"]), ref: "reset" },
                { name: tr(_A["openfile"]["name"]), description: tr(_A["openfile"]["description"]), ref: "openfile" },
                { name: tr(_A["promptresult"]["name"]), description: tr(_A["promptresult"]["description"]), ref: "promptresult" },
                { name: tr(_A["httpauth"]["name"]), description: tr(_A["httpauth"]["description"]), ref: "httpauth" },
                { name: tr(_A["scroll"]["name"]), description: tr(_A["scroll"]["description"]), ref: "scroll" },
                { name: tr(_A["renderscreen"]["name"]), description: tr(_A["renderscreen"]["description"]), ref: "renderscreen" },
                { name: tr(_A["solvecaptcha"]["name"]), description: tr(_A["solvecaptcha"]["description"]), ref: "solvecaptcha" },
                { name: tr(_A["solverfailed"]["name"]), description: tr(_A["solverfailed"]["description"]), ref: "solverfailed" },
                { name: tr(_A["timeout"]["name"]), description: tr(_A["timeout"]["description"]), ref: "timeout" },
                { name: tr(_A["browsersettings"]["name"]), description: tr(_A["browsersettings"]["description"]), ref: "browsersettings" },
                { name: tr(_A["mousesettings"]["name"]), description: tr(_A["mousesettings"]["description"]), ref: "mousesettings" },
                { description: tr("Script logic"), type: "group", name: "logic", icon: _G["logic"]["icon"], info: tr(_G["logic"]["info"]) },
                { name: tr(_A["if"]["name"]), description: tr(_A["if"]["description"]), ref: "if" },
                { name: tr(_A["while"]["name"]), description: tr(_A["while"]["description"]), ref: "while" },
                { name: tr(_A["for"]["name"]), description: tr(_A["for"]["description"]), ref: "for" },
                { name: tr(_A["foreach"]["name"]), description: tr(_A["foreach"]["description"]), ref: "foreach" },
                { name: tr(_A["break"]["name"]), description: tr(_A["break"]["description"]), ref: "break" },
                { name: tr(_A["continue"]["name"]), description: tr(_A["continue"]["description"]), ref: "continue" },
                { name: tr(_A["success"]["name"]), description: tr(_A["success"]["description"]), ref: "success" },
                { name: tr(_A["fail"]["name"]), description: tr(_A["fail"]["description"]), ref: "fail" },
                { name: tr(_A["die"]["name"]), description: tr(_A["die"]["description"]), ref: "die" },
                { name: tr(_A["label"]["name"]), description: tr(_A["label"]["description"]), ref: "label" },
                { name: tr(_A["goto"]["name"]), description: tr(_A["goto"]["description"]), ref: "goto" },
                { name: tr(_A["ignoreerrors"]["name"]), description: tr(_A["ignoreerrors"]["description"]), ref: "ignoreerrors" },
                { name: tr(_A["setvariable"]["name"]), description: tr(_A["setvariable"]["description"]), ref: "setvariable" },
                { name: tr(_A["incvariable"]["name"]), description: tr(_A["incvariable"]["description"]), ref: "incvariable" },
                { name: tr(_A["globalset"]["name"]), description: tr(_A["globalset"]["description"]), ref: "globalset" },
                { name: tr(_A["incglobalvariable"]["name"]), description: tr(_A["incglobalvariable"]["description"]), ref: "incglobalvariable" },
                { name: tr(_A["executefunction"]["name"]), description: tr(_A["executefunction"]["description"]), ref: "executefunction" },
                { name: tr(_A["executefunctioninseveralthreads"]["name"]), description: tr(_A["executefunctioninseveralthreads"]["description"]), ref: "executefunctioninseveralthreads" },
                { description: tr("Tools"), type: "group", name: "tools", icon: _G["tools"]["icon"], info: tr(_G["tools"]["info"]) },
                { name: tr(_A["log"]["name"]), description: tr(_A["log"]["description"]), ref: "log" },
                { name: tr(_A["clearlog"]["name"]), description: tr(_A["clearlog"]["description"]), ref: "clearlog" },
                { name: tr(_A["result"]["name"]), description: tr(_A["result"]["description"]), ref: "result" },
                { name: tr(_A["custom"]["name"]), description: tr(_A["custom"]["description"]), ref: "custom" },
                { name: tr(_A["base64"]["name"]), description: tr(_A["base64"]["description"]), ref: "base64" },
                /*{ name: tr(_A["globalget"]["name"]), description: tr(_A["globalget"]["description"]), ref: "globalget" },*/
                { name: tr(_A["parseline"]["name"]), description: tr(_A["parseline"]["description"]), ref: "parseline" },
                { name: tr(_A["template"]["name"]), description: tr(_A["template"]["description"]), ref: "template" },
                { name: tr(_A["replacestring"]["name"]), description: tr(_A["replacestring"]["description"]), ref: "replacestring" },
                { name: tr(_A["randomstring"]["name"]), description: tr(_A["randomstring"]["description"]), ref: "randomstring" },
                { name: tr(_A["randomint"]["name"]), description: tr(_A["randomint"]["description"]), ref: "randomint" },
                { description: tr("Network"), type: "group", name: "network", icon: _G["network"]["icon"], info: tr(_G["network"]["info"]) },
                { name: tr(_A["setheader"]["name"]), description: tr(_A["setheader"]["description"]), ref: "setheader" },
                { name: tr(_A["getcookiesforurl"]["name"]), description: tr(_A["getcookiesforurl"]["description"]), ref: "getcookiesforurl" },
                { name: tr(_A["savecookies"]["name"]), description: tr(_A["savecookies"]["description"]), ref: "savecookies" },
                { name: tr(_A["restorecookies"]["name"]), description: tr(_A["restorecookies"]["description"]), ref: "restorecookies" },
                { name: tr(_A["loadcookiesfromhttpclient"]["name"]), description: tr(_A["loadcookiesfromhttpclient"]["description"]), ref: "loadcookiesfromhttpclient" },
                { name: tr(_A["cachemaskallow"]["name"]), description: tr(_A["cachemaskallow"]["description"]), ref: "cachemaskallow" },
                { name: tr(_A["cachemaskdeny"]["name"]), description: tr(_A["cachemaskdeny"]["description"]), ref: "cachemaskdeny" },
                { name: tr(_A["requestmaskallow"]["name"]), description: tr(_A["requestmaskallow"]["description"]), ref: "requestmaskallow" },
                { name: tr(_A["requestmaskdeny"]["name"]), description: tr(_A["requestmaskdeny"]["description"]), ref: "requestmaskdeny" },
                { name: tr(_A["cleardata"]["name"]), description: tr(_A["cleardata"]["description"]), ref: "cleardata" },
                { name: tr(_A["clearmasks"]["name"]), description: tr(_A["clearmasks"]["description"]), ref: "clearmasks" },
                { name: tr(_A["getstatus"]["name"]), description: tr(_A["getstatus"]["description"]), ref: "getstatus" },
                { name: tr(_A["isloaded"]["name"]), description: tr(_A["isloaded"]["description"]), ref: "isloaded" },
                { name: tr(_A["getfromcache"]["name"]), description: tr(_A["getfromcache"]["description"]), ref: "getfromcache" },
                { name: tr(_A["restrictpopups"]["name"]), description: tr(_A["restrictpopups"]["description"]), ref: "restrictpopups" },
                { name: tr(_A["allowpopups"]["name"]), description: tr(_A["allowpopups"]["description"]), ref: "allowpopups" },
                { name: tr(_A["restrictdownloads"]["name"]), description: tr(_A["restrictdownloads"]["description"]), ref: "restrictdownloads" },
                { name: tr(_A["allowdownloads"]["name"]), description: tr(_A["allowdownloads"]["description"]), ref: "allowdownloads" },
                { description: tr("Waiters"), type: "group", name: "waiters", icon: _G["waiters"]["icon"], info: tr(_G["waiters"]["info"]) },
                { name: tr(_A["waitfullload"]["name"]), description: tr(_A["waitfullload"]["description"]), ref: "waitfullload" },
                { name: tr(_A["waitload"]["name"]), description: tr(_A["waitload"]["description"]), ref: "waitload" },
                { name: tr(_A["waiturl"]["name"]), description: tr(_A["waiturl"]["description"]), ref: "waiturl" },
                { name: tr(_A["waitcontent"]["name"]), description: tr(_A["waitcontent"]["description"]), ref: "waitcontent" },
                { name: tr(_A["waitcss"]["name"]), description: tr(_A["waitcss"]["description"]), ref: "waitcss" },
                { name: tr(_A["waitfiledownload"]["name"]), description: tr(_A["waitfiledownload"]["description"]), ref: "waitfiledownload" },
                { name: tr(_A["sleep"]["name"]), description: tr(_A["sleep"]["description"]), ref: "sleep" },
                { description: tr("Email"), type: "group", name: "email", icon: _G["email"]["icon"], info: tr(_G["email"]["info"]) },
                { name: tr(_A["emailsettings"]["name"]), description: tr(_A["emailsettings"]["description"]), ref: "emailsettings" },
                { name: tr(_A["emailproxy"]["name"]), description: tr(_A["emailproxy"]["description"]), ref: "emailproxy" },
                { name: tr(_A["emaillength"]["name"]), description: tr(_A["emaillength"]["description"]), ref: "emaillength" },
                { name: tr(_A["emailsearchfirst"]["name"]), description: tr(_A["emailsearchfirst"]["description"]), ref: "emailsearchfirst" },
                { name: tr(_A["emailsearchall"]["name"]), description: tr(_A["emailsearchall"]["description"]), ref: "emailsearchall" },
                { name: tr(_A["emailpull"]["name"]), description: tr(_A["emailpull"]["description"]), ref: "emailpull" },
                { description: tr("Http Client"), type: "group", name: "httpclient", icon: _G["httpclient"]["icon"], info: tr(_G["httpclient"]["info"]) },
                { name: tr(_A["httpclientproxy"]["name"]), description: tr(_A["httpclientproxy"]["description"]), ref: "httpclientproxy" },
                { name: tr(_A["httpclientreset"]["name"]), description: tr(_A["httpclientreset"]["description"]), ref: "httpclientreset" },
                { name: tr(_A["httpclientget"]["name"]), description: tr(_A["httpclientget"]["description"]), ref: "httpclientget" },
                { name: tr(_A["httpclientpost"]["name"]), description: tr(_A["httpclientpost"]["description"]), ref: "httpclientpost" },
                { name: tr(_A["httpclientdownload"]["name"]), description: tr(_A["httpclientdownload"]["description"]), ref: "httpclientdownload" },
                { name: tr(_A["httpclienturl"]["name"]), description: tr(_A["httpclienturl"]["description"]), ref: "httpclienturl" },
                { name: tr(_A["httpclientcontent"]["name"]), description: tr(_A["httpclientcontent"]["description"]), ref: "httpclientcontent" },
                { name: tr(_A["httpclientstatus"]["name"]), description: tr(_A["httpclientstatus"]["description"]), ref: "httpclientstatus" },
                { name: tr(_A["httpclientgetheader"]["name"]), description: tr(_A["httpclientgetheader"]["description"]), ref: "httpclientgetheader" },
                { name: tr(_A["httpclientsetheader"]["name"]), description: tr(_A["httpclientsetheader"]["description"]), ref: "httpclientsetheader" },
                { name: tr(_A["httpclientclearheader"]["name"]), description: tr(_A["httpclientclearheader"]["description"]), ref: "httpclientclearheader" },
                { name: tr(_A["httpclientgetcookiesforurl"]["name"]), description: tr(_A["httpclientgetcookiesforurl"]["description"]), ref: "httpclientgetcookiesforurl" },
                { name: tr(_A["httpclientsavecookies"]["name"]), description: tr(_A["httpclientsavecookies"]["description"]), ref: "httpclientsavecookies" },
                { name: tr(_A["httpclientrestorecookies"]["name"]), description: tr(_A["httpclientrestorecookies"]["description"]), ref: "httpclientrestorecookies" },
                { name: tr(_A["loadcookiesfrombrowser"]["name"]), description: tr(_A["loadcookiesfrombrowser"]["description"]), ref: "loadcookiesfrombrowser" },
                { name: tr(_A["httpclientfailonerror"]["name"]), description: tr(_A["httpclientfailonerror"]["description"]), ref: "httpclientfailonerror" },
                { name: tr(_A["httpclientiserror"]["name"]), description: tr(_A["httpclientiserror"]["description"]), ref: "httpclientiserror" },
                { name: tr(_A["httpclientgeterrorstring"]["name"]), description: tr(_A["httpclientgeterrorstring"]["description"]), ref: "httpclientgeterrorstring" },
                { name: tr(_A["httpclientxpathxml"]["name"]), description: tr(_A["httpclientxpathxml"]["description"]), ref: "httpclientxpathxml" },
                { name: tr(_A["httpclientxpathxmllist"]["name"]), description: tr(_A["httpclientxpathxmllist"]["description"]), ref: "httpclientxpathxmllist" },
                { name: tr(_A["httpclientxpathtext"]["name"]), description: tr(_A["httpclientxpathtext"]["description"]), ref: "httpclientxpathtext" },
                { name: tr(_A["httpclientxpathtextlist"]["name"]), description: tr(_A["httpclientxpathtextlist"]["description"]), ref: "httpclientxpathtextlist" },
                { name: tr(_A["httpclientxpathcount"]["name"]), description: tr(_A["httpclientxpathcount"]["description"]), ref: "httpclientxpathcount" },
                { name: tr(_A["httpclientxpathexists"]["name"]), description: tr(_A["httpclientxpathexists"]["description"]), ref: "httpclientxpathexists" },
                { description: tr("Manual browser control"), type: "group", name: "manual", icon: _G["manual"]["icon"], info: tr(_G["manual"]["info"]) },
                { name: tr(_A["openbrowser"]["name"]), description: tr(_A["openbrowser"]["description"]), ref: "openbrowser" },
                { name: tr(_A["closebrowser"]["name"]), description: tr(_A["closebrowser"]["description"]), ref: "closebrowser" }
                _MACRO_INSERT_ACTION_LIST_

            ]);

    var _A2G = {}

    var CurrentGroup = ""

    for(var i=0; i<_TaskCollection.length; i++)
    {
      var el = _TaskCollection.models[i]
      if(el.get("type") == "group")
      {
        CurrentGroup = el.get("name")
        _G[CurrentGroup]["name"] = el.get("description")
      }else
      {
        _A2G[el.get("ref")] = CurrentGroup
      }
    }

    var _PreserveMainPosition = new PreserveMainPosition();

    var _GobalModel = new GobalModel();

    var _SelectorModel = new SelectorModel();

    var _MainView = new MainView({collection: _TaskCollection, model: _GobalModel});

    var _ResourceCollection = new ResourceCollection();

    var _VariableCollection = new VariableCollection();

    var _GlobalVariableCollection = new GlobalVariableCollection();

    var _Schema = [];

    var _FunctionCollection = new FunctionCollection();
 
    var _LabelCollection = new LabelCollection();

    var _ExpressionEditor = null;

    var ToolboxMaximizeCallback = null;

    var ActionHistory = []

    var BookmarkList = []

    var CurrentGroup = ""

    var CurrentTab = ""

    var BookmarkDrop = null;

    var RemoveBookmarkDrop = null;

    var BookmarkDrag = [];

    var OnHold = false;

    var CurrentDat = null;

    /* Preserve execute type */

    var BrowserAutomationStudio_LastExecuteType = "executeandadd"

    function BrowserAutomationStudio_SetExecuteType()
    {
      if(typeof(BrowserAutomationStudio_LastExecuteType) == "undefined")
      {
        BrowserAutomationStudio_LastExecuteType = "executeandadd"
      }
      $("#executetype button").removeClass("btn-info")
      $("#executetype button").addClass("btn-default")

      $("#executetype *[data-action=" + BrowserAutomationStudio_LastExecuteType + "]").removeClass("btn-default").addClass("btn-info")
    }

    /* Test path */


    var BrowserAutomationStudio_TestPathLastPath = ""

    function BrowserAutomationStudio_TestPathInternal()
    {
      
      var clear_highlight = true;
      var path = "page().highlight()!" + "\n" + "section_start(\"test\",-3)!"
      if($("#selector-input").length > 0)
      {
        var loader = new ResourceLoader();
        var p = GetPath(loader,true,true)
        path = p["path"] + ".highlight()!" + "\n" + "section_start(\"test\",-3)!"
        var selector = "";
        if(p["query"])
        {
          selector = ";_SELECTOR=" + p["query"] + ";"
        }
        path = loader.GetAdditionalData() + selector + path
        clear_highlight = false
      }
      
      if(typeof(BrowserAutomationStudio_TestPathLastPath) == "undefined")
        BrowserAutomationStudio_TestPathLastPath = ""

      if(BrowserAutomationStudio_TestPathLastPath != path)
      {

        BrowserAutomationStudio_TestPathFirstTry = false

        var prev = BrowserAutomationStudio_TestPathLastPath

        BrowserAutomationStudio_TestPathLastPath = path

        if(prev != "" && typeof(OnHold) == "boolean" && OnHold == false)
        {
          if(clear_highlight)
          {
            BrowserAutomationStudio_SetPathCount("0")
            BrowserAutomationStudio_ClearHighlight()  
          }else
          {
            BrowserAutomationStudio_SetPathCount("")
            BrowserAutomationStudio_Execute(path)
          }
        }
      }
    }

    function BrowserAutomationStudio_SetPathCount(count)
    {
      if(count.toString().length > 0)
      {
        $("#PathCount").css("visibility","visible")
        $("#PathCount").html(count)
      }else
      {
        $("#PathCount").css("visibility","hidden")
      }
      
    }



    /* Bookmarks history */
    function BrowserAutomationStudio_DisableDragFunction(ev)
    {
        var img = document.createElement('img')
        img.src = ''
        ev.dataTransfer.setDragImage(img, 0, 0)
    }

    function BrowserAutomationStudio_SaveBookmarks()
    {
      if(CurrentTab == "bookmarks")
      {
        BookmarkList = []
        $(".leftactionpaneltitlebody a").toArray().forEach(function(el){
          var ref = $(el).attr("data-ref")
          BookmarkList.push(ref)
        })
        BrowserAutomationStudio_PreserveInterfaceState();
        
      }
      
    }

    function BrowserAutomationStudio_InstallBookmarks()
    {
      if(BookmarkDrag)
      {
        BookmarkDrag.forEach(function(el){
          el.destroy()
        })
      }
      BookmarkDrag = []
      $(".panel-group").toArray().forEach(function(el){
        el.ondragstart = BrowserAutomationStudio_DisableDragFunction
        BookmarkDrag.push(Sortable.create(el, {
          group: {
            name: 'input',
            pull: "clone",
            put: function(e){return false;}
          },
          draggable: ".toolbutton",
          onStart: function () {
            $(".tool").removeClass("toolhover")
          },

          onEnd: function () {
            $(".tool").removeClass("toolhover")
            BrowserAutomationStudio_SaveBookmarks();
          },
          ghostClass: 'ghost',

          sort: false,
          animation: 70
        }))
      })
    }


    function BrowserAutomationStudio_ShowHideHistory()
    {
      if(CurrentTab.length == 0)
      {
        BrowserAutomationStudio_RenderHistory();
        
        return;
      }

      if(CurrentTab == "bookmarks")
      {
        BrowserAutomationStudio_RenderHistory();
        return;
      }

      if(CurrentTab == "history")
      {
        BrowserAutomationStudio_HideHistoryBookmarks();
        return;
      }
      
    }

    function BrowserAutomationStudio_ShowHideBookmarks()
    {

      if(CurrentTab.length == 0)
      {
        BrowserAutomationStudio_RenderBookmarks();
        return;
      }

      if(CurrentTab == "history")
      {
        BrowserAutomationStudio_RenderBookmarks();
        return;
      }

      if(CurrentTab == "bookmarks")
      {
        BrowserAutomationStudio_HideHistoryBookmarks();
        return;
      }
    }

    function BrowserAutomationStudio_HideHistoryBookmarks()
    {
      $(".leftactionpaneltitledrop").hide()

      $(".leftactionpanel").hide()
      $(".mainscreen").css('margin-left','37px');
      CurrentTab = ""
      BrowserAutomationStudio_PreserveInterfaceState()
      $("#showhistory").removeClass("btn-primary").removeClass("btn-default").addClass("btn-default")
      $("#showbookmarks").removeClass("btn-primary").removeClass("btn-default").addClass("btn-default")

    }

    function BrowserAutomationStudio_RenderBookmarks()
    {
      $(".leftactionpaneltitledrop").hide()
      $(".leftactionpanel").show()
      $(".mainscreen").css('margin-left','259px');
        
      $(".leftactionpaneltitle").html('<div>' + tr('Bookmarks') + '</div><div style="color:gray">' + tr('Drag actions here') + '</div>')
      CurrentTab = "bookmarks"; 
      BrowserAutomationStudio_PreserveInterfaceState()
      

      $("#showhistory").removeClass("btn-primary").removeClass("btn-default").addClass("btn-default")
      $("#showbookmarks").removeClass("btn-primary").removeClass("btn-default").addClass("btn-primary")

      var render = ""
      BookmarkList.forEach(function(el){
        var name = ""
        if(_A[el])
        {
            name = tr(_A[el]["name"])
        }
        render += '<a class="toolbutton" href="#!/' + el + '" data-ref="' + el + '"><div class="tool"><span class="toolinner">' + name + '</span></div></a>'
      })


      $(".leftactionpaneltitlebody").html(render)

      if(BookmarkDrop)
        BookmarkDrop.destroy()

      BookmarkDrop = null

      if(RemoveBookmarkDrop)
        RemoveBookmarkDrop.destroy()

      RemoveBookmarkDrop = null

      var leftactionpaneltitledrop = $(".leftactionpaneltitledrop")
      if(leftactionpaneltitledrop.length > 0)
      {
        $(".leftactionpaneltitledrop")[0].ondragstart = BrowserAutomationStudio_DisableDragFunction

        RemoveBookmarkDrop = Sortable.create($(".leftactionpaneltitledrop")[0], {
          group: {
            name: 'output',
            put: function(e)
            {
              return true;
            }
          },
          onAdd: function (evt) {
            var el = evt.item;
            el.parentNode.removeChild(el);
          },
          onEnd: function () {
            $(".tool").removeClass("toolhover")
            BrowserAutomationStudio_SaveBookmarks();
          },
          animation: 70
        });
      }



      var leftactionpaneltitlebody = $(".leftactionpaneltitlebody")
      if(leftactionpaneltitlebody.length > 0)
      {
        $(".leftactionpaneltitlebody")[0].ondragstart = BrowserAutomationStudio_DisableDragFunction

        BookmarkDrop = Sortable.create($(".leftactionpaneltitlebody")[0], {
          group: {
            name: 'output',
            put: function(e){
              return true;
            }
          },

          onStart: function (e) {
            $(".leftactionpaneltitledrop").show()
          },

          onEnd: function (e) {
            $(".leftactionpaneltitledrop").hide()
            BrowserAutomationStudio_SaveBookmarks();

          },
          onAdd: function (e) {
            var item = e.item;
            if(BookmarkList.indexOf($(item).attr("data-ref")) >= 0)
              item.parentNode.removeChild(item);

          },

          ghostClass: 'ghost',
          animation: 70
        });
      }

    }

    function BrowserAutomationStudio_RenderHistory()
    {
      $(".leftactionpaneltitledrop").hide()
      $(".leftactionpanel").show()
      $(".mainscreen").css('margin-left','259px');
        
      $(".leftactionpaneltitle").html('<div>' + tr('History') + '</div><div style="color:gray">' + tr('Your recent actions') + '</div>')
      CurrentTab = "history";
      BrowserAutomationStudio_PreserveInterfaceState()
      $("#showhistory").removeClass("btn-primary").removeClass("btn-default").addClass("btn-primary")
      $("#showbookmarks").removeClass("btn-primary").removeClass("btn-default").addClass("btn-default")
      
      var data = "";

      _.each(ActionHistory, function(Action) {
        if(_A[Action])
        {
          data += '<a href="#!/' + Action + '"><div class="tool"><span class="toolinner">' + tr(_A[Action]["name"]) + '</span></div></a>'
        }
        
      })

      $(".leftactionpaneltitlebody").html(data)

      if(BookmarkDrop)
        BookmarkDrop.destroy()

      BookmarkDrop = null
      
    }




    function BrowserAutomationStudio_ReturnToMainFunction()
    {
      $(".mainscreen *[data-group]").hide()
      $(".mainscreen *[data-group-all").show()
      $(".actions")[0].scrollTop = 0
      CurrentGroup = ""
    }

    function BrowserAutomationStudio_GotoGroup(group)
    {
        $(".mainscreen *[data-group]").hide()
        $(".mainscreen *[data-group=" + group + "]").show()
        $(".actions")[0].scrollTop = 0
        CurrentGroup = group
    }


    // Action history

    _Router.on("route", function(route, params) {
      if(route != "main" && _A[route] && _A[route]["class"] != "browser")
      {
        var index = ActionHistory.indexOf(route)
        if(index >= 0)
          ActionHistory.splice(index,1)

        ActionHistory.splice(0,0,route);
        ActionHistory = ActionHistory.slice(0,10);
        BrowserAutomationStudio_PreserveInterfaceState();
      }
    });

    function BrowserAutomationStudio_PreserveInterfaceState()
    {
      BrowserAutomationStudio_SaveInterfaceState(JSON.stringify({history: ActionHistory,tab: CurrentTab, bookmarks: BookmarkList}));
    }

    function BrowserAutomationStudio_LoadInterfaceState(interface_json)
    {
      try
      {
        var interface_obj = JSON.parse(interface_json)
        ActionHistory = interface_obj["history"]
        BookmarkList = interface_obj["bookmarks"]
        var tab = interface_obj["tab"] || ""
        if(tab == "history")
        {
          BrowserAutomationStudio_RenderHistory();
        }else if (tab == "bookmarks")
        {
          BrowserAutomationStudio_RenderBookmarks();
        }
      }catch(e){}

    }


    function BrowserAutomationStudio_MaximizeCallback()
    {
      if(ToolboxMaximizeCallback)
      {
        ToolboxMaximizeCallback();
        ToolboxMaximizeCallback = null
      }
    }

    Backbone.history.start();

    $( document ).ready(function() {
        document.documentElement.style.zoom = _Z + '%';
        /*$( document.body ).click(function(){
          $("#searchinput").focus()  

        })*/
        $( document ).click(function(){
          $(".dropdown-menu-css-options").hide()
        })

        $( window ).resize(function() {
          $(".actions").css("height", window.innerHeight * (100.0 / _Z) - 40 + "px")
          $(".leftactionpanel").css("height", window.innerHeight * (100.0 / _Z) - 45 + "px")
          $(".leftactionpaneltitlebody").css("min-height", window.innerHeight * (100.0 / _Z) - 95 + "px")

        });

        $(document).keyup(function(e) {
          if (e.keyCode == 27)
          {

            if($('.modal.in').length > 0)
            {
              $('#' + $('.modal.in').attr("id")).modal('hide');
              return;
            }

            if($("#expressioneditor-container").is(":visible"))
            {
              $("#expressioneditor-cancel").click()
              return;
            }

            if($(".returntomain").is(":visible") && CurrentGroup != "")
            {
              BrowserAutomationStudio_ReturnToMainFunction();
              return;
            }
            
            var el = $("#backtomain")
            if(el.length > 0)
            {
              el[0].click()
            }
            
          }
          if (e.keyCode == 13)
          {

            if( e.target.nodeName == "TEXTAREA" ) return


            if($('.modal.in').length > 0)
            {
              return;
            }

            if($("#expressioneditor-container").is(":visible"))
            {
              return;
            }

            if($(".returntomain").is(":visible") && CurrentGroup != "")
            {
              return;
            }
            
            var el = $("#ok")
            if(el.length > 0)
            {
              el[0].click()
            }
            
          }
        });
    });

    function Invalid(data)
    {
      console.log("Invalid");
      $("#validation").html(data)
      $("#validation").removeClass("text-muted").removeClass("text-danger").addClass("text-danger")
      
    }

    function je(data)
    {
      return data
      .replace(new RegExp("\\\\","g"),"\\u005c")
      .replace(new RegExp("<","g"),"\\u003c")
      .replace(new RegExp(">","g"),"\\u003e")
      .replace(new RegExp("\"","g"),"\\u0022")
      .replace(new RegExp("'","g"),"\\u0027")
      .replace(new RegExp("&","g"),"\\u0026")
      .replace(new RegExp("{","g"),"\\u007b")
      .replace(new RegExp("}","g"),"\\u007d")

      .replace(new RegExp("\\n","g"),"\\n")
      .replace(new RegExp("\\r","g"),"\\r")
    }

    function jsort(json)
    {
      return json.sort(function (a, b) {
        if (a["name"].toLowerCase() > b["name"].toLowerCase()) {
          return 1;
        }
        if (a["name"].toLowerCase() < b["name"].toLowerCase()) {
          return -1;
        }
        return 0;
      })
    }

    function utf8_to_b64( str ) {
        return window.btoa(unescape(encodeURIComponent( str )));
    }

    function b64_to_utf8( str ) {
        return decodeURIComponent(escape(window.atob( str )));
    }

    function BrowserAutomationStudio_GetWaitCode()
    {
      var usewaiter = $("#use-waiter")

      if(usewaiter.length > 0 && usewaiter.attr("data-enabled") == "true")  
      {
        return "\n" + timeout_waiter() + "\nwait_async_load()!"
      }

      return "";
    }

    function timeout_general()
    {
      var usewaiter = $("#use-timeout")
      if(usewaiter.length == 0)
        return ""
      var timeout_value = usewaiter.attr("data-value")
        if(timeout_value.length == 0)
          timeout_value = "0"

      timeout_value = parseInt(timeout_value) * 1000

      if(usewaiter.length > 0 && usewaiter.attr("data-enabled") == "true" && timeout_value != "0")  
      {
        return "general_timeout_next(" + timeout_value + ")"
      }

      return "" 
    }

    function timeout_solver()
    {
      var usewaiter = $("#use-timeout")
      if(usewaiter.length == 0)
        return ""
      var timeout_value = usewaiter.attr("data-value")
        if(timeout_value.length == 0)
          timeout_value = "0"

      timeout_value = parseInt(timeout_value) * 1000

      if(usewaiter.length > 0 && usewaiter.attr("data-enabled") == "true" && timeout_value != "0")  
      {
        return "solver_timeout_next(" + timeout_value + ")"
      }

      return "" 
    }

    function timeout_value()
    {
      var usewaiter = $("#use-timeout")
      if(usewaiter.length == 0)
        return 0
      var timeout_value = usewaiter.attr("data-value")
        if(timeout_value.length == 0)
          timeout_value = "0"

      timeout_value = parseInt(timeout_value) * 1000

      if(usewaiter.length > 0 && usewaiter.attr("data-enabled") == "true" && timeout_value != "0")  
      {
        return timeout_value
      }

      return 0 
    }

    function timeout_waiter()
    {
      var usewaiter = $("#use-timeout")
      if(usewaiter.length == 0)
        return ""
      var timeout_value = usewaiter.attr("data-value")
        if(timeout_value.length == 0)
          timeout_value = "0"

      timeout_value = parseInt(timeout_value) * 1000

      if(usewaiter.length > 0 && usewaiter.attr("data-enabled") == "true" && timeout_value != "0")  
      {
        return "waiter_timeout_next(" + timeout_value + ")"
      }

      return "" 
    }

    function BrowserAutomationStudio_GetTargetCode(loader)
    {
      var usetarget = $("#use-target")

      if(usetarget.length > 0 && usetarget.attr("data-enabled") == "true")  
      {
        var TargetUrl = GetInputConstructorValue("TargetUrl",loader);
        var TargetTabNumber = GetInputConstructorValue("TargetTabNumber",loader);
        return "\n_set_target({url:" + TargetUrl["updated"] + ",tab:" + TargetTabNumber["updated"] + "})\n"
      }

      return "";
    }

    function BrowserAutomationStudio_GetMoveJson(loader)
    {
      var usemove = $("#use-move")

      if(usemove.length > 0 && usemove.attr("data-enabled") == "true")  
      {
        var Speed = GetInputConstructorValue("Speed",loader);
        var Gravity = GetInputConstructorValue("Gravity",loader);
        var Deviation = GetInputConstructorValue("Deviation",loader);
        return ' {"speed": ' + Speed["updated"] + ',"gravity": ' +  Gravity["updated"] + ',"deviation": ' + Deviation["updated"] + '} '
      }

      return ' {} ';
    }

    function BrowserAutomationStudio_UsesWaitCode()
    {
      var usewaiter = $("#use-waiter")
      if(usewaiter.length > 0 && usewaiter.attr("data-enabled") == "true")  
        return true
      return false
    }

    function BrowserAutomationStudio_ThreadNumberEdit()
    {
        _Router.navigate("#!/threadnumber", true);
    }

    function BrowserAutomationStudio_RunFunction()
    {
        _Router.navigate("#!/executefunction", true);
    }

    function BrowserAutomationStudio_RunFunctionSeveralThreads()
    {
        _Router.navigate("#!/executefunctioninseveralthreads", true); 
    }

    function BrowserAutomationStudio_SuccessNumberEdit()
    {
        _Router.navigate("#!/successnumber", true);
    }

    function BrowserAutomationStudio_FailNumberEdit()
    {
        _Router.navigate("#!/failnumber", true);
    }

    function BrowserAutomationStudio_SaveControls(additional)
    {
      var loader = new ResourceLoader();

      var ControlsText = {s:_GobalModel.get("state"),v: 1}

      if(additional)
        ControlsText = Object.assign({},ControlsText, additional);

      ControlsText["f"] = _Filter.GetModels()
      
      var usewaiter = $("#use-waiter")
      if(usewaiter.length > 0 && usewaiter.attr("data-enabled") == "true")  
      {
        ControlsText["uw"] = "1"
      }else
      {
        ControlsText["uw"] = "0"
      }

      var usetarget = $("#use-target")
      if(usetarget.length > 0 && usetarget.attr("data-enabled") == "true")  
      {
        ControlsText["ut"] = "1"
      }else
      {
        ControlsText["ut"] = "0"
      }

      var usetimeout = $("#use-timeout")
      if(usetimeout.length > 0 && usetimeout.attr("data-enabled") == "true")  
      {
        ControlsText["uto"] = "1"
        ControlsText["uti"] = $("#timeout-val").html()
      }else
      {
        ControlsText["uto"] = "0"
      }

      var usemove = $("#use-move")
      if(usemove.length > 0 && usemove.attr("data-enabled") == "true")  
      {
        ControlsText["um"] = "1"
      }else
      {
        ControlsText["um"] = "0"
      }

      var ControlList = $("*[data-preserve=true]")
      var Elements = []

      for(var i = 0;i<ControlList.length;i++)
      {
        var el = $(ControlList[i])
        var NewElement = {}
        var id = el.attr("data-preserve-id")
        var type = el.attr("data-preserve-type")
        var json = el.attr("data-preserve-json")


        NewElement["id"] = id
        NewElement["type"] = type
        NewElement["json"] = json


        if(type == "constr")
        {
          NewElement["data"] = GetInputConstructorValue(id,loader)["original"]
          NewElement["class"] = $("*[data-selector-id=" + id + "]").html()
        }else if(type == "var")
        {
          NewElement["data"] = $("#" + id).val()
        }else if(type == "select")
        {
          NewElement["data"] = $("#" + id).val()
        }else if(type == "check")
        {
          NewElement["data"] = $("#" + id).prop("checked")
        }else if(type == "text")
        {
          NewElement["data"] =  $("#" + id).val()
        }

        Elements.push(NewElement)
      }
      ControlsText["d"] = Elements
      if($(".path").length>0 || $(".path2").length>0)
      {
        var all = {}
        var json = _SelectorModel.toJSON()
        all["is_image"] = json["is_image"]
        if(json["is_image"])
        {
          //all["image_data"] = json["image_data"]
          /*all["scroll"] = json["scroll"]
          all["threshold"] = json["threshold"]*/
        }else
        {
          var current = json["current"]

          
          all["css"] = json["css"]
          all["version"] = json["version"]
          all["css1"] = ("css1" in json) ? json["css1"] : ""
          all["css2"] = ("css2" in json) ? json["css2"] : ""
          all["css3"] = ("css3" in json) ? json["css3"] : ""
          all["current"] = current
          all["match"] = json["match"]
          all["xpath"] = json["xpath"]
          all["at"] = json["mousex"] + ", " + json["mousey"]

          if(current!="none")
            all[current] = $("#selector-input").val()

          
        }
        if($("#checkbox-wait-element").length > 0)
          all["we"] = $("#checkbox-wait-element").prop("checked")
        
        if($("#checkbox-fail-action").length > 0)
          all["fa"] = $("#checkbox-fail-action").prop("checked")

        ControlsText["p"] = all
      }

      ControlsText = "/*Dat:" + utf8_to_b64(JSON.stringify(ControlsText)) +  "*/\n"
      return ControlsText
    }

    function BrowserAutomationStudio_EditStart(dataraw)
    {
      _SelectorModel.set("is_editing",true)
      var data = JSON.parse(b64_to_utf8(dataraw))
      CurrentDat = data
      

      if("p" in data)
      {
        var selector = data["p"]
        _SelectorModel.set("is_image",selector["is_image"])

        if(selector["is_image"])
        {
          //console.log(data["d"])
          //_SelectorModel.set("image_data",data["d"]["ImageBase64"]["data"])
          /*_SelectorModel.set("threshold",selector["threshold"])
          _SelectorModel.set("scroll",selector["scroll"])*/
        }else
        {
          _SelectorModel.set("css",selector["css"])

          if("css1" in selector)
            _SelectorModel.set("css1",selector["css1"])
          else
            _SelectorModel.set("css1","")
          
          if("css2" in selector)
            _SelectorModel.set("css2",selector["css2"])
          else
            _SelectorModel.set("css2","")
          
          if("css3" in selector)
            _SelectorModel.set("css3",selector["css3"])
          else
            _SelectorModel.set("css3","")

          _SelectorModel.set("match",selector["match"])
          _SelectorModel.set("xpath",selector["xpath"] || "")
          var split = selector["at"].split(",")
          _SelectorModel.set("mousex",split[0].replace(/\s/g, ''))
          _SelectorModel.set("mousey",split[split.length - 1].replace(/\s/g, ''))
          _SelectorModel.set("current",selector["current"])
          _SelectorModel.set("version",selector["version"])
        }

      }

      _GobalModel.set({ state: data["s"] });
      _GobalModel.set("isedit",true)

      $("#executetype").hide()

      if("p" in data)
      {
        if(typeof(selector["we"]) != "undefined")
        {
          $("#checkbox-wait-element").prop("checked", selector["we"]);
        }
        
        if(typeof(selector["fa"]) != "undefined")
        {
          $("#checkbox-fail-action").prop("checked", selector["fa"]);
        }
      }

      if(data["uw"] == "1")
      {
        $("#use-waiter").attr("data-enabled","true")
        $("#use-waiter").removeClass().addClass("use-waiter-enabled")
      }else if(data["uw"] == "0")
      {
        $("#use-waiter").attr("data-enabled","false")
        $("#use-waiter").removeClass().addClass("use-waiter-disabled")
      }

      


      if(data["ut"]  == "1")
      {
        $("#use-target").attr("data-enabled","true")
        $("#use-target").removeClass().addClass("use-target-enabled")
        $("#target-data").show()
      }else if(data["ut"] == "0")
      {
        $("#use-target").attr("data-enabled","false")
        $("#use-target").removeClass().addClass("use-target-disabled")
        $("#target-data").hide()
      }

      if(data["um"]  == "1")
      {
        $("#use-move").attr("data-enabled","true")
        $("#use-move").removeClass().addClass("use-move-enabled")
        $("#move-data").show()
      }else if(data["um"] == "0")
      {
        $("#use-move").attr("data-enabled","false")
        $("#use-move").removeClass().addClass("use-move-disabled")
        $("#move-data").hide()
      }

      var timeout_value = 0
      if(data["uto"]  == "1")
        timeout_value = parseInt(data["uti"])
      

      $("#use-timeout").attr("data-value", (typeof(timeout_value) != "undefined" && timeout_value > 0) ? timeout_value : "0")
                        .attr("class", ((typeof(timeout_value) != "undefined" && timeout_value > 0) ? "" : "use-timeout-disabled") + " trtitle")
                        .attr("data-enabled", (typeof(timeout_value) != "undefined" && timeout_value > 0) ? "true" : "false")

      $("#timeout-val").html((typeof(timeout_value) != "undefined" && timeout_value > 0) ? ("" + timeout_value) : "")
      if(typeof(timeout_value) != "undefined" && timeout_value > 0)
      {
        $("#timeout-is-default").hide()
      }else
      {
        $("#timeout-is-default").show()
      }


      
      for(var i = 0;i<data["d"].length;i++)
      {
        var el = data["d"][i]
        
        var id = el["id"]
        var type = el["type"]
        var _data = el["data"]

        if(id == "ImageBase64")
        {
          _SelectorModel.set("image_data",_data)
          $("#ImageData").attr("src","data:image/png;base64," + _SelectorModel.get("image_data"))
        }

        if(type == "constr")
        {
          
          var _class = el["class"]
          $("*[data-preserve-id=" + id + "] a." + _class).click()
          $("*[data-preserve-id=" + id + "]").attr("data-preserve-json",el["json"])
          if(_class == "int")
          {
            $("#" + id + "_number").val(parseInt(_data))
          }else
            $("#" + id).val(_data)

        }else if(type == "check")
        {
          $("#" + id).prop("checked",_data);
        }else
        {
          $("#" + id).val(_data);
        }

      }
      _MainView.tablechange();
      if(typeof(data["f"]) != "undefined" && data["f"])
        _Filter.RestoreModels(data["f"])
    }

    function BrowserAutomationStudio_EditEnd()
    {
      _GobalModel.set("isedit",false)
      _GobalModel.set({ state: "main" });
    }


    function BrowserAutomationStudio_SetResources(resources, additional_resources)
    {
      _ResourceCollection.reset()

      var res = JSON.parse(resources)
      var additional_res = JSON.parse(additional_resources) 

      for(var i = 0;i < res.length;i+=1)
      {
        _ResourceCollection.add({name:res[i]["name"],description:res[i]["description"]})
      }

      for(var i = 0;i < additional_res.length;i+=1)
      {
        _ResourceCollection.add({name:additional_res[i]["name"],description:additional_res[i]["name"]})
      }
    }

    function BrowserAutomationStudio_SetVariables(variables)
    {
      _VariableCollection.reset()
      var res = JSON.parse(variables);
      var added_cycle_index = false
      for(var i = 0;i < res.length;i+=1)
      {
        if(res[i]["name"] == "CYCLE_INDEX")
          added_cycle_index = true
      }
      if(!added_cycle_index)
        res.push({name:"CYCLE_INDEX"})
      
      res.sort(function(a,b){return a["name"] >= b["name"]})

      for(var i = 0;i < res.length;i+=1)
      {
        _VariableCollection.add({name:res[i]["name"]})
      }
    }

    function BrowserAutomationStudio_SetGlobalVariables(global_variables)
    {

      _GlobalVariableCollection.reset()
      var res = JSON.parse(global_variables)
      res.sort(function(a,b){return a["name"] >= b["name"]})
      var added_cycle_index = false
      for(var i = 0;i < res.length;i+=1)
      {
        _GlobalVariableCollection.add({name:res[i]["name"]})
      }
    }

    function BrowserAutomationStudio_SetSchema(schema)
    {
      _Schema = JSON.parse(schema)
      _Filter.Install(_Schema)
      _MainView.render()
    }

    function BrowserAutomationStudio_SetFunctions(functions)
    {
      _FunctionCollection.reset()
      var res = JSON.parse(functions)

      for(var i = 0;i < res.length;i+=1)
      {
        _FunctionCollection.add({name:res[i]["name"]})
      }
    }

    function BrowserAutomationStudio_SetLabels(labels)
    {
      _LabelCollection.reset()
      var res = JSON.parse(labels)

      for(var i = 0;i < res.length;i+=1)
      {
        _LabelCollection.add({name:res[i]["name"]})
      }
    }

    function GetInputConstructorValue(id, loader)
    {

        var ResTextTypeIsString = $("*[data-selector-id=" + id + "]").html() == "string";
        var ResTextTypeIsInt = $("*[data-selector-id=" + id + "]").html() == "int";

        var ResText;
        if(ResTextTypeIsString)
          ResText = $("#" + id).val();
        else if(ResTextTypeIsInt)
          ResText = $("#" + id + "_number").val();
        else
          ResText = $("#" + id).val();

        loader.SetIsString(ResTextTypeIsString)
        var ResTextUpdated = loader.Resolve(ResText+"");
        if(ResTextUpdated.length == 0)
          ResTextUpdated = "\"\""
        return {"updated" : ResTextUpdated, "original" : ResText}
    }

    function GetPath(loader, need_all, need_visible)
    {
      if(_SelectorModel.get("is_image"))
      {
        var waitelement = true
        var failaction = true
        if($("#checkbox-wait-element").length > 0)
        {
          waitelement = $("#checkbox-wait-element").prop("checked") 
        }

        if($("#checkbox-fail-action").length > 0)
        {
          failaction = $("#checkbox-fail-action").prop("checked") 
        }

        var scroll = 'data["scroll"] = ' + GetInputConstructorValue("Scroll",loader)["updated"] + ' == "scroll";'
        var threshold = 'data["threshold"] = parseInt(' + GetInputConstructorValue("Threshold",loader)["updated"] + ');'
        var timeout = timeout_value()
        if(timeout == 0)
          timeout = 60000
        timeout = 'data["timeout"] = ' + timeout + ';'

        var dataraw = GetInputConstructorValue("ImageBase64",loader)["updated"]
        
        var data = 'data["data"] = "' + dataraw + '";'

        var rawnodata = scroll + threshold + timeout
        var raw = rawnodata + data

        var resultwaiter = ""
        var resultpath = ""

        resultwaiter = "var data = {fail:" + failaction + ",wait:" + waitelement + "};" + raw + "_wait_image(data)!"
        resultpath = "_image()"

        return {path: resultpath,waiter: resultwaiter, imagesearch:true}

      }else if(_SelectorModel.get("version") == "1.0" || $("#selector-input").val().indexOf(">CSS>") >= 0 || $("#selector-input").val().indexOf(">MATCH>") >= 0|| $("#selector-input").val().indexOf(">FRAME>") >= 0|| $("#selector-input").val().indexOf(">XPATH>") >= 0 || $("#selector-input").val().indexOf(">AT>") >= 0 || _SelectorModel.get("current") == "xpath")
      {
        //New selectors
       
        var raw = $("#selector-input").val()

        var current = _SelectorModel.get("current")
        if(current == "none")
          return {path:"page()",waiter:"",raw:"", querycss: je(_SelectorModel.get("css")), querycss2: je(_SelectorModel.get("css2")), querycss3: je(_SelectorModel.get("css3")), querymatch: je(_SelectorModel.get("match")), queryxpath: je(_SelectorModel.get("xpath"))}

        if(current == "at")
          return {path:"position(" + raw + ")",waiter:"", raw:"position " + raw, querycss: je(_SelectorModel.get("css")), querycss2: je(_SelectorModel.get("css2")), querycss3: je(_SelectorModel.get("css3")), querymatch: je(_SelectorModel.get("match")), queryxpath: je(_SelectorModel.get("xpath"))}

        loader.SetIsString(true)
        var raw_not_escaped = raw
        raw = loader.Resolve(raw+"")


        var waiter_func_name = "wait_element";
        if((typeof(need_visible) != "undefined" && need_visible))
        {
          waiter_func_name = "wait_element_visible"
        }

        var waitelement = true
        var failaction = true
        if($("#checkbox-wait-element").length > 0)
        {
          waitelement = $("#checkbox-wait-element").prop("checked") 
        }

        if($("#checkbox-fail-action").length > 0)
        {
          failaction = $("#checkbox-fail-action").prop("checked") 
        }
        

        var querycss = _SelectorModel.get("css")
        var querycss2 = _SelectorModel.get("css2")
        var querycss3 = _SelectorModel.get("css3")
        var querymatch = _SelectorModel.get("match")
        var queryxpath = _SelectorModel.get("xpath")

        if(current == "css")
        {
          querycss = raw
          querymatch = loader.Resolve(querymatch+"")
          queryxpath = loader.Resolve(queryxpath+"")
        }
        if(current == "match")
        {
          querymatch = raw
          querycss = loader.Resolve(querycss+"")
          queryxpath = loader.Resolve(queryxpath+"")
        }
        if(current == "xpath")
        {
          queryxpath = raw
          querycss = loader.Resolve(querycss+"")
          querymatch = loader.Resolve(querymatch+"")
        }

        var resultpath = "get_element_selector(_SELECTOR, " + (typeof(need_all) != "undefined" && need_all).toString() + ")"
        var resultwaiter = "_SELECTOR = " + raw + ";"

        if(waitelement == true && failaction == true)
        {
          resultwaiter += timeout_waiter() + "\n" + waiter_func_name + "(_SELECTOR)!"
        }else if(waitelement == false && failaction == true)
        {
          resultwaiter += "get_element_selector(_SELECTOR, false).exist()! if(_result()=='0')fail('Element " + JSON.stringify(raw_not_escaped) + " not exists');"
          resultpath += ".nowait()"
        }else if(waitelement == true && failaction == false)
        {
          resultwaiter += timeout_waiter() + "\nwaiter_nofail_next();\n" + waiter_func_name + "(_SELECTOR)!"
          resultpath += ".nowait()"
        }else if(waitelement == false && failaction == false)
        {
          resultpath += ".nowait()"
        }

        return {path: resultpath,waiter: resultwaiter,raw:"css " + raw_not_escaped, querycss: querycss, querycss2: querycss2, querycss3: querycss3, querymatch: querymatch, queryxpath: queryxpath, query: raw}
        
       
      }
      else
      {
        //Old selectors
        var current = _SelectorModel.get("current")
        if(current == "none")
          return {path:"page()",waiter:"",raw:"", querycss: '"' + je(_SelectorModel.get("css")) + '"', querycss2: '"' + je(_SelectorModel.get("css2")) + '"', querycss3: '"' + je(_SelectorModel.get("css3")) + '"', querymatch: '"' + je(_SelectorModel.get("match")) + '"'}

        var raw_not_escaped = $("#selector-input").val()
        var raw_original = $("#selector-input").val()
        var index = ""

        var index_match = raw_not_escaped.match(/\s*\<\s*([^\>\<]+)\s*\>\s*$/)
        if(index_match)
        {
          index = index_match[1]
          raw_not_escaped = raw_not_escaped.replace(/\<\s*([^\>\<]+)\s*\>\s*$/,"")
        }

        var raw = raw_not_escaped

        var frames_array = []
        var frames_path = ""
        while(true)
        {
          var indexcss = raw.indexOf(">css>")
          var indexmatch = raw.indexOf(">match>")

          if(indexcss < 0 && indexmatch < 0)
            break;

          if(indexcss >= 0 && (indexmatch < 0 || indexcss < indexmatch))
          {
            var frame_item = raw.substring(0,indexcss)
            

            loader.SetIsString(true)
            frame_item = loader.Resolve(frame_item+"")
            frames_array.push("{type: \"css\", data: " + frame_item + "}");
            
            frames_path += "frame_css(" + frame_item + ")."
            indexcss += ">css>".length
            raw = raw.substring(indexcss,raw.length)
            continue;
          }

          if(indexmatch >= 0 && (indexcss < 0 || indexmatch < indexcss))
          {
            var frame_item = raw.substring(0,indexmatch)

            loader.SetIsString(true)
            frame_item = loader.Resolve(frame_item+"")     
            frames_array.push("{type: \"match\", data: " + frame_item + "}");
            
            frames_path += "frame_match(" + frame_item + ")."
            indexmatch += ">match>".length
            raw = raw.substring(indexmatch,raw.length)
            continue;
          }

        }

        loader.SetIsString(true)
        raw = loader.Resolve(raw+"")

        if(index.length > 0)
        {
          loader.SetIsString(false)
          index = loader.Resolve(index+"")
        }
        

        if(current == "css")
        {
          var path = "css"

          if(index.length > 0 || (typeof(need_all) != "undefined" && need_all))
            path = "all"

          path += "(" + raw + ")"

          if(index.length > 0)
            path += ".at(" + index + ")"

          var waiter_func_name = "wait_css";
          if((typeof(need_visible) != "undefined" && need_visible))
          {
            waiter_func_name = "wait_css_visible"
          }

          var raw_object = ["raw:" + raw, "frames:" + "[" + frames_array.join(",") + "]"]
          
          if(index.length > 0)
            raw_object.push("index:" + index)

          raw = "{" + raw_object.join(",") + "}"

          return {path:frames_path + path,waiter: timeout_waiter() + "\n" + waiter_func_name + "(" + raw + ")!",raw:"css " + raw_not_escaped, querycss: '"' + je(raw_original) + '"', querycss2: '"' + je(_SelectorModel.get("css2")) + '"', querycss3: '"' + je(_SelectorModel.get("css3")) + '"', querymatch: '"' + je(_SelectorModel.get("match")) + '"'}
        }

        if(current == "match")
        {
          var path = "match"

          if(index.length > 0 || (typeof(need_all) != "undefined" && need_all))
            path = "match_all"

          path += "(" + raw + ")"

          if(index.length > 0)
            path += ".at(" + index + ")"

          var waiter_func_name = "wait_content";
          if((typeof(need_visible) != "undefined" && need_visible))
          {
            waiter_func_name = "wait_content_visible"
          }

          var raw_object = ["raw:" + raw, "frames:" + "[" + frames_array.join(",") + "]"]
          
          if(index.length > 0)
            raw_object.push("index:" + index)

          raw = "{" + raw_object.join(",") + "}"

          return {path:frames_path + path,waiter: timeout_waiter() + "\n" + waiter_func_name + "(" + raw + ")!", raw:"match " + raw_not_escaped, querycss: '"' + je(_SelectorModel.get("css")) + '"', querycss2: '"' + je(_SelectorModel.get("css2")) + '"', querycss3: '"' + je(_SelectorModel.get("css3")) + '"', querymatch: '"' + je(raw_original) + '"'}
        }

        if(current == "at")
          return {path:"position(" + raw + ")",waiter:"", raw:"position " + raw_not_escaped, querycss: '"' + je(_SelectorModel.get("css")) + '"', querycss2: '"' + je(_SelectorModel.get("css2")) + '"', querycss3: '"' + je(_SelectorModel.get("css3")) + '"', querymatch: '"' + je(_SelectorModel.get("match")) + '"'}

        return {path:"page()",waiter:"",raw:"", query: "", querycss: '"' + je(_SelectorModel.get("css")) + '"', querycss2: '"' + je(_SelectorModel.get("css2")) + '"', querycss3: '"' + je(_SelectorModel.get("css3")) + '"', querymatch: '"' + je(_SelectorModel.get("match")) + '"'}
      }
    }

    function InsertAtCaret(areaId,text)
    {
        var txtarea = document.getElementById(areaId);
        var scrollPos = txtarea.scrollTop;
        var strPos = 0;
        var br = ((txtarea.selectionStart || txtarea.selectionStart == '0') ?
            "ff" : (document.selection ? "ie" : false ) );
        if (br == "ie") {
            txtarea.focus();
            var range = document.selection.createRange();
            range.moveStart ('character', -txtarea.value.length);
            strPos = range.text.length;
        }
        else if (br == "ff") strPos = txtarea.selectionStart;

        var front = (txtarea.value).substring(0,strPos);
        var back = (txtarea.value).substring(strPos,txtarea.value.length);
        txtarea.value=front+text+back;
        strPos = strPos + text.length;
        if (br == "ie") {
            txtarea.focus();
            var range = document.selection.createRange();
            range.moveStart ('character', -txtarea.value.length);
            range.moveStart ('character', strPos);
            range.moveEnd ('character', 0);
            range.select();
        }
        else if (br == "ff") {
            txtarea.selectionStart = strPos;
            txtarea.selectionEnd = strPos;
            txtarea.focus();
        }
        txtarea.scrollTop = scrollPos;
    }

    function ResourceLoader()
    {
      var AdditionalData = "";
      var IsString = true;
      var IsPrerender = false;
      var IsJsonStringify = false;

      this.Resolve = function(str)
      {
        var res = this.ResolveResources(str);
        //res = this.ResolveVariables(res);
        return res;
      }

      this.SetIsString = function(value)
      {
        IsString = value;
      }

      this.SetIsPrerender = function(value)
      {
        IsPrerender = value;
      }

      this.SetIsJsonStringify = function(value)
      {
        IsJsonStringify = value;
      }

      this.ResolveVariables = function(str)
      {
        var res = "";
        var reg = new RegExp("\\[\\[([^\\]]+)\\]\\]")
        var rest = str
        var all = ""
        while(true)
        {
          all = res
          if(res.length > 0 && rest.length > 0)
            all += ((IsString) ? " + " : "")

          if(rest.length > 0)
            all += ((IsString) ? "\"" : "") + ((IsString) ? je(rest) : rest) + ((IsString) ? "\"" : "")

          var match = reg.exec(rest)
          if(!match)
            break;

          var i = match.index
          var resnew = "";
          if(i>0)
          {
            resnew += (IsString) ? "\"" : ""
            resnew += (IsString) ? je(rest.substr(0,i)) : rest.substr(0,i)
            resnew += (IsString) ? "\" + " : ""
          }

          if(IsPrerender)
            resnew += match[0]
          else
          {
            var match_add = match[1]
            if(match_add.indexOf("GLOBAL:") >= 0)
            {
              match_add = "JSON.parse(P(\"basglobal\", " + JSON.stringify(match_add.substr(7)) + ") || '\"\"')";
            }else
            {
              match_add = "VAR_" + match_add
            }

            if(IsJsonStringify)
            {
              match_add = "JSON.stringify(" + match_add + ")"
            }
            resnew += match_add
            
          }


          i = match.index + match[0].length
          var j = rest.length - i
          if(j>0)
          {
            rest = rest.substr(i,j)
          }else
            rest = ""

          if(res.length == 0)
            res = resnew
          else
            res +=  ((IsString) ? " + " : "") + resnew


        }
        return all;
      }

      this.ResolveResources = function(str)
      {
        var res = "";
        var reg = new RegExp("\\{\\{([^\\}]+)\\}\\}")
        var rest = str
        var all = ""
        while(true)
        {
          all = res
          if(res.length > 0 && rest.length > 0)
            all += ((IsString) ? " + " : "")

          if(rest.length > 0)
            all += this.ResolveVariables(rest)

          var match = reg.exec(rest)
          if(!match)
            break;
          var Iteration = Math.floor(Math.random() * (999999 - 100000) + 100000)

          var v = "RESOURCE_" + Iteration;
          var m = match[1].split("|")[0]
          var notreuse = match[1].indexOf("|notreuse")>=0
          var onlyfail = match[1].indexOf("|onlyfail")>=0
          AdditionalData +=  _.template($('#resource_code').html())({resource:m,variable:v,notreuse:notreuse,onlyfail:onlyfail});

          var i = match.index
          var resnew = "";
          if(i>0)
          {
            resnew += this.ResolveVariables(rest.substr(0,i))
            resnew += ((IsString) ? " + " : "")
          }

          if(IsPrerender)
            resnew += match[0]
          else
            resnew += (IsJsonStringify) ? "JSON.stringify(" + v + ")" : v

          i = match.index + match[0].length
          var j = rest.length - i
          if(j>0)
          {
            rest = rest.substr(i,j)
          }else
            rest = ""

          if(res.length == 0)
            res = resnew
          else
            res +=  ((IsString) ? " + " : "") + resnew


        }
        return all;
      }

      this.GetAdditionalData = function()
      {
        return AdditionalData;
      }

    }

    function BrowserAutomationStudio_AddTab()
    {
      _Router.navigate("#!/addtab", true);
    }

    function BrowserAutomationStudio_SelectTab(i)
    {
      _Router.navigate("#!/selecttab", true);
      _GobalModel.set("index",i)
    }

    function BrowserAutomationStudio_CloseTab(i)
    {
      _Router.navigate("#!/closetab", true);
      _GobalModel.set("index",i)
    }


    function BrowserAutomationStudio_Click(x, y)
    {
      _Router.navigate("#!/click", true);
      _GobalModel.set("x",x.toString())
      _GobalModel.set("y",y.toString())
    }

    function BrowserAutomationStudio_Move(x, y)
    {
      _Router.navigate("#!/move", true);
      _GobalModel.set("x",x.toString())
      _GobalModel.set("y",y.toString())
      
    }

    function BrowserAutomationStudio_MoveAndClick(x, y)
    {
      _Router.navigate("#!/moveandclick", true);
      _GobalModel.set("x",x.toString())
      _GobalModel.set("y",y.toString())
      
    }

    function BrowserAutomationStudio_Drag(x, y)
    {
      _Router.navigate("#!/drag", true);
      _GobalModel.set("x",x.toString())
      _GobalModel.set("y",y.toString())
    }

    function BrowserAutomationStudio_Drop(x, y)
    {
      _Router.navigate("#!/drop", true);
      _GobalModel.set("x",x.toString())
      _GobalModel.set("y",y.toString())
    }

    function BrowserAutomationStudio_ElementFunction(selector, name, is_loop)
    {
      console.log(selector)
      _SelectorModel.set("is_editing",false)
      _SelectorModel.set("version","1.0")
      var need_to_set_image_data = false

      _Router.navigate("#", true);
      if(is_loop !== 1)
      {
        if(typeof(selector) == "string")
        {
          need_to_set_image_data = true
          _SelectorModel.set("is_image",true)
          _SelectorModel.set("image_data",selector)
        }else
        {
          _SelectorModel.set("is_image",false)
          _SelectorModel.set("css",selector["css"])
          _SelectorModel.set("css1",selector["css1"])
          if("css2" in selector)
            _SelectorModel.set("css2",selector["css2"])
          else
            _SelectorModel.set("css2","")

          if("css3" in selector)
            _SelectorModel.set("css3",selector["css3"])
          else
            _SelectorModel.set("css3","")

          _SelectorModel.set("match",selector["match"])
          _SelectorModel.set("xpath",selector["xpath"] || "")
        }

      }
      else
      {
        if(_.pluck(_VariableCollection.toJSON(), 'name').indexOf("FOR_EACH_CSS") < 0)
        {
          bootbox.alert(tr("Start Loop to use this function"))
          return
        }

        _SelectorModel.set("css","[[FOR_EACH_CSS]]>AT>[[CYCLE_INDEX]]")
        _SelectorModel.set("css1","[[FOR_EACH_CSS]]>AT>[[CYCLE_INDEX]]")
        _SelectorModel.set("css2","")
        _SelectorModel.set("css3","")
        _SelectorModel.set("match","[[FOR_EACH_MATCH]]>AT>[[CYCLE_INDEX]]")
        _SelectorModel.set("xpath","[[FOR_EACH_XPATH]]>AT>[[CYCLE_INDEX]]")

      }
      _SelectorModel.set("mousex",parseInt(selector["mousex"]))
      _SelectorModel.set("mousey",parseInt(selector["mousey"]))

      _Router.navigate("#!/" + name, true);
      if(need_to_set_image_data)
      {
        $("#ImageBase64").val(_SelectorModel.get("image_data"))
        $("#ImageData").attr("src","data:image/png;base64," + _SelectorModel.get("image_data"))

      }
    }

    function BrowserAutomationStudio_LoopElement(selector)
    {
      BrowserAutomationStudio_ElementFunction(selector, "loopelement", false)
    }

    _MACRO_INSERT_ELEMENT_FUNCTION_

    function BrowserAutomationStudio_Wait(selector, is_loop)
    {
      BrowserAutomationStudio_ElementFunction(selector, "waitelement", is_loop)
    }

    function BrowserAutomationStudio_GetXml(selector, is_loop)
    {
      BrowserAutomationStudio_ElementFunction(selector, "xml", is_loop)
    }

    function BrowserAutomationStudio_GetText(selector, is_loop)
    {
      BrowserAutomationStudio_ElementFunction(selector, "text", is_loop)
    }

    function BrowserAutomationStudio_ExecuteScript(selector, is_loop)
    {
      BrowserAutomationStudio_ElementFunction(selector, "script", is_loop)
    }


    function BrowserAutomationStudio_ClickElement(selector, is_loop)
    {
      BrowserAutomationStudio_ElementFunction(selector, "clickelement", is_loop)
    }
    function BrowserAutomationStudio_MoveElement(selector, is_loop)
    {
      BrowserAutomationStudio_ElementFunction(selector, "moveelement", is_loop)
    }
    function BrowserAutomationStudio_DragElement(selector, is_loop)
    {
      BrowserAutomationStudio_ElementFunction(selector, "dragelement", is_loop)
    }
    function BrowserAutomationStudio_DropElement(selector, is_loop)
    {
      BrowserAutomationStudio_ElementFunction(selector, "dropelement", is_loop)
    }
    function BrowserAutomationStudio_MoveAndClickElement(selector, is_loop)
    {
      BrowserAutomationStudio_ElementFunction(selector, "moveandclickelement", is_loop)
    }
    function BrowserAutomationStudio_Clear(selector, is_loop)
    {
      BrowserAutomationStudio_ElementFunction(selector, "clear", is_loop)
    }
    function BrowserAutomationStudio_Type(selector, is_loop)
    {
      BrowserAutomationStudio_ElementFunction(selector, "typeelement", is_loop)
    }
    function BrowserAutomationStudio_Exists(selector, is_loop)
    {
      BrowserAutomationStudio_ElementFunction(selector, "exist", is_loop)
    }
    function BrowserAutomationStudio_Style(selector, is_loop)
    {
      BrowserAutomationStudio_ElementFunction(selector, "style", is_loop)
    }
    function BrowserAutomationStudio_Check(selector, is_loop)
    {
      BrowserAutomationStudio_ElementFunction(selector, "check", is_loop)
    }
    function BrowserAutomationStudio_Focus(selector, is_loop)
    {
      BrowserAutomationStudio_ElementFunction(selector, "focus", is_loop)
    }
    function BrowserAutomationStudio_Set(selector, is_loop)
    {
      BrowserAutomationStudio_ElementFunction(selector, "set", is_loop)
    }
    function BrowserAutomationStudio_SetInteger(selector, is_loop)
    {
      BrowserAutomationStudio_ElementFunction(selector, "set_integer", is_loop)
    }
    function BrowserAutomationStudio_SetRandom(selector, is_loop)
    {
      BrowserAutomationStudio_ElementFunction(selector, "set_random", is_loop)
    }
    function BrowserAutomationStudio_GetAttr(selector, is_loop)
    {
      BrowserAutomationStudio_ElementFunction(selector, "attr", is_loop)
    }
    function BrowserAutomationStudio_SetAttr(selector, is_loop)
    {
      BrowserAutomationStudio_ElementFunction(selector, "set_attr", is_loop)
    }
    function BrowserAutomationStudio_Captcha(selector, is_loop)
    {
      BrowserAutomationStudio_ElementFunction(selector, "captcha", is_loop)
    }
    function BrowserAutomationStudio_Length(selector)
    {
      BrowserAutomationStudio_ElementFunction(selector, "length", false)
    }
    function BrowserAutomationStudio_Screenshot(selector, is_loop)
    {
      BrowserAutomationStudio_ElementFunction(selector, "screenshot", is_loop)
    }
    function BrowserAutomationStudio_GetCoordinates(selector, is_loop)
    {
      BrowserAutomationStudio_ElementFunction(selector, "coordinates", is_loop)
    }

    function BrowserAutomationStudio_ShowWaiting(code)
    {
      OnHold = true
      $(".modal").modal('hide')
      var text = prepare_title_code(code,"")
      if(text.length > 0)
      {
        $("#WaitingActionName").html(text)
        $("#InterruptMessage").hide()
        $("#WaitingDisable").show()
        $('#WaitingModal').modal({keyboard: false,backdrop: 'static'})
      }
          
    }
    function BrowserAutomationStudio_HideWaiting()
    {
      OnHold = false
      $('#WaitingModal').modal('hide')
    }

    function Normalize(code, tab)
    {
      var a = code.split("\n")
      var res = "";
      for(var i=0;i<a.length;i+=1)
      {
        var l = a[i].trim()
        if(l.length == 0)
          continue;

        if(res.length != 0)
        {
          res += "\n"
        }
        for(var j = 0;j<tab;j+=1)
          res += "   "
        res += l
      }
      return res
    }


  </script>

</body>
</html>
